update format specific handling. (#502)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Thu, 20 Feb 2020 14:48:28 +0000 (07:48 -0700)
committerGitHub <noreply@github.com>
Thu, 20 Feb 2020 14:48:28 +0000 (07:48 -0700)
* update format specific handling.

Format specific allocate, copy, destroy functions use new/delete for
underlying data management.  Use brace intitializers for underlying
data.  Previous xmalloc/xcalloc and xfree were used.

Format specific copy functions use copy constructor of underlying data.

Format specific copy functions have a const source.

Format specific functions use static_cast instead of c-style casts.
This helps avoid casting away const accidentally.

When possible, assign the result of fs_chain_find to a const pointer.

Eliminate corruption of global lists by AN1 writer which was modifying
format specific data.  This also simplifies memomry management and
fixes a double delete.

Fix const correctness issues with an1 symbol lookup.

Correct an1 symbol lookup to avoid dependency on structure padding.

Catch make-an1sym.pl with an1sym.h.

* use reinterpret_cast w/ fs_chain_add fs_chain_find ...

instead of c-style casts.

* make format_specifc_data a base class

and the various flavors derived classes.

* use a QList for format_specific_data chains.

* split format specific defines ...

use reinterpret_cast to downcast format_specific_data.  dynamic_cast
is noticeably slower.

* add new formspec.h file.

* create FormatSpecificDataList class.

rename format specific related items.

* safety check for formspec nullptr function ptrs.

* replace format specific function pointers

with pure virtual clone function and dtor.

32 files changed:
CMakeLists.txt
GPSBabel.pro
Makefile.in
an1.cc
an1sym.h
bend.cc
defs.h
destinator.cc
formspec.cc
formspec.h [new file with mode: 0644]
g7towin.cc
garmin_fs.cc
garmin_fs.h
garmin_gpi.cc
garmin_txt.cc
gdb.cc
gpx.cc
gpx.h
html.cc
interpolate.cc
kml.cc
lowranceusr.cc
make-an1sym.pl
ozi.cc
random.cc
route.cc
src/core/xmltag.h
text.cc
unicsv.cc
waypt.cc
xcsv.cc
xmltag.cc

index 1ab759a464154d6ea18af5e1ecc5509e2cd21594..356c20f442b8e9890a938ddf4a62b31dca675a5b 100644 (file)
@@ -111,6 +111,7 @@ set(HEADERS
   filter.h
   filter_vecs.h
   format.h
+  formspec.h
   garmin_device_xml.h
   garmin_fs.h
   garmin_gpi.h
index 1efcacf3bb083313d478839b94a9dbad09fb4009..9ea05dd279dda456e1efec71e97b24b9fa36d946 100644 (file)
@@ -99,6 +99,7 @@ HEADERS =  \
        filter.h \
        filter_vecs.h \
        format.h \
+       formspec.h \
        garmin_device_xml.h \
        garmin_fs.h \
        garmin_gpi.h \
index 9eaeba83f01003f83e8afd1842e43049f73ebbd4..4981783b5055a578186bd9d4d219666cbe9a0457 100644 (file)
@@ -426,279 +426,295 @@ mac/libusb/libusb-1.0.a:
        cd mac/libusb; $(QMAKE) @abs_srcdir@/mac/libusb/libusb.pro && $(MAKE)
 
 # Machine generated from here down.
-alan.o: alan.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h
-an1.o: an1.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h an1sym.h
-arcdist.o: arcdist.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+alan.o: alan.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
+an1.o: an1.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
+  an1sym.h
+arcdist.o: arcdist.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   arcdist.h filter.h grtcirc.h src/core/logging.h
-bcr.o: bcr.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h csv_util.h \
-  garmin_tables.h
-bend.o: bend.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h bend.h \
-  filter.h grtcirc.h
+bcr.o: bcr.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
+  csv_util.h garmin_tables.h
+bend.o: bend.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
+  bend.h filter.h grtcirc.h
 brauniger_iq.o: brauniger_iq.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
-  cet.h inifile.h gbfile.h session.h src/core/datetime.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
   src/core/optional.h gbser.h
-bushnell.o: bushnell.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
+bushnell.o: bushnell.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h
 bushnell_trl.o: bushnell_trl.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
-  cet.h inifile.h gbfile.h session.h src/core/datetime.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
   src/core/optional.h
-cet.o: cet.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h
-cet_util.o: cet_util.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  cet_util.h src/core/logging.h
-compegps.o: compegps.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  cet_util.h csv_util.h jeeps/gpsmath.h jeeps/gpsport.h
-cst.o: cst.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h cet_util.h
-csv_util.o: csv_util.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  csv_util.h src/core/logging.h
-delgpl.o: delgpl.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+cet.o: cet.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
+  cet.h
+cet_util.o: cet_util.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h cet_util.h src/core/logging.h
+compegps.o: compegps.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h cet_util.h csv_util.h jeeps/gpsmath.h \
+  jeeps/gpsport.h
+cst.o: cst.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
+  cet_util.h
+csv_util.o: csv_util.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h csv_util.h src/core/logging.h
+delgpl.o: delgpl.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
 destinator.o: destinator.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
-  cet.h inifile.h gbfile.h session.h src/core/datetime.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
   src/core/optional.h garmin_fs.h jeeps/gps.h jeeps/../defs.h \
   jeeps/gpsport.h jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h \
   jeeps/gpsutil.h jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h \
   jeeps/gpsfmt.h jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h \
   strptime.h
-dg-100.o: dg-100.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+dg-100.o: dg-100.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   gbser.h
-discard.o: discard.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+discard.o: discard.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   discard.h filter.h
-dmtlog.o: dmtlog.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+dmtlog.o: dmtlog.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   jeeps/gpsmath.h jeeps/gpsport.h xmlgeneric.h
-duplicate.o: duplicate.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  duplicate.h filter.h
-easygps.o: easygps.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+duplicate.o: duplicate.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h duplicate.h filter.h
+easygps.o: easygps.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
 energympro.o: energympro.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
-  cet.h inifile.h gbfile.h session.h src/core/datetime.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
   src/core/optional.h
-enigma.o: enigma.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+enigma.o: enigma.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
-exif.o: exif.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h \
+exif.o: exif.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   garmin_tables.h jeeps/gpsmath.h jeeps/gpsport.h
 explorist_ini.o: explorist_ini.cc defs.h config.h zlib/zlib.h \
-  zlib/zconf.h cet.h inifile.h gbfile.h session.h src/core/datetime.h \
-  src/core/optional.h explorist_ini.h
+  zlib/zconf.h formspec.h inifile.h gbfile.h session.h \
+  src/core/datetime.h src/core/optional.h explorist_ini.h
 f90g_track.o: f90g_track.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
-  cet.h inifile.h gbfile.h session.h src/core/datetime.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
   src/core/optional.h
-fatal.o: fatal.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+fatal.o: fatal.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
 filter_vecs.o: filter_vecs.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
-  cet.h inifile.h gbfile.h session.h src/core/datetime.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
   src/core/optional.h filter_vecs.h arcdist.h filter.h bend.h discard.h \
-  duplicate.h height.h interpolate.h nukedata.h polygon.h position.h \
-  radius.h reverse_route.h smplrout.h sort.h stackfilter.h swapdata.h \
-  trackfilter.h transform.h validate.h gbversion.h vecs.h format.h gpx.h \
-  src/core/file.h src/core/xmlstreamwriter.h src/core/xmltag.h \
-  legacyformat.h
-formspec.o: formspec.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
-g7towin.o: g7towin.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+  duplicate.h height.h heightgrid.h interpolate.h nukedata.h polygon.h \
+  position.h radius.h reverse_route.h smplrout.h sort.h stackfilter.h \
+  swapdata.h trackfilter.h transform.h validate.h gbversion.h vecs.h \
+  format.h ggv_bin.h gpx.h src/core/file.h src/core/xmlstreamwriter.h \
+  src/core/xmltag.h legacyformat.h mynav.h xcsv.h garmin_fs.h \
+  jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h jeeps/gpsdevice.h \
+  jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h jeeps/gpsapp.h \
+  jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h jeeps/gpsmath.h \
+  jeeps/gpsmem.h jeeps/gpsrqst.h src/core/textstream.h
+formspec.o: formspec.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h
+g7towin.o: g7towin.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   cet_util.h csv_util.h garmin_fs.h jeeps/gps.h jeeps/../defs.h \
   jeeps/gpsport.h jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h \
   jeeps/gpsutil.h jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h \
   jeeps/gpsfmt.h jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h \
   garmin_tables.h strptime.h
-garmin.o: garmin.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+garmin.o: garmin.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   cet_util.h format.h garmin_device_xml.h garmin_fs.h jeeps/gps.h \
   jeeps/../defs.h jeeps/gpsport.h jeeps/gpsdevice.h jeeps/gpssend.h \
   jeeps/gpsread.h jeeps/gpsutil.h jeeps/gpsapp.h jeeps/gpsprot.h \
   jeeps/gpscom.h jeeps/gpsfmt.h jeeps/gpsmath.h jeeps/gpsmem.h \
   jeeps/gpsrqst.h garmin_tables.h grtcirc.h jeeps/gpsserial.h vecs.h \
-  gpx.h src/core/file.h src/core/xmlstreamwriter.h src/core/xmltag.h \
-  legacyformat.h
+  ggv_bin.h gpx.h src/core/file.h src/core/xmlstreamwriter.h \
+  src/core/xmltag.h legacyformat.h mynav.h xcsv.h src/core/textstream.h
 garmin_device_xml.o: garmin_device_xml.cc defs.h config.h zlib/zlib.h \
-  zlib/zconf.h cet.h inifile.h gbfile.h session.h src/core/datetime.h \
-  src/core/optional.h garmin_device_xml.h xmlgeneric.h
+  zlib/zconf.h formspec.h inifile.h gbfile.h session.h \
+  src/core/datetime.h src/core/optional.h garmin_device_xml.h \
+  xmlgeneric.h
 garmin_fit.o: garmin_fit.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
-  cet.h inifile.h gbfile.h session.h src/core/datetime.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
   src/core/optional.h jeeps/gpsmath.h jeeps/gpsport.h
-garmin_fs.o: garmin_fs.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  cet_util.h garmin_fs.h jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h \
-  jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
-  jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
-  jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h garmin_tables.h
+garmin_fs.o: garmin_fs.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h garmin_fs.h jeeps/gps.h jeeps/../defs.h \
+  jeeps/gpsport.h jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h \
+  jeeps/gpsutil.h jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h \
+  jeeps/gpsfmt.h jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h \
+  garmin_tables.h
 garmin_gpi.o: garmin_gpi.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
-  cet.h inifile.h gbfile.h session.h src/core/datetime.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
   src/core/optional.h garmin_gpi.h cet_util.h garmin_fs.h jeeps/gps.h \
   jeeps/../defs.h jeeps/gpsport.h jeeps/gpsdevice.h jeeps/gpssend.h \
   jeeps/gpsread.h jeeps/gpsutil.h jeeps/gpsapp.h jeeps/gpsprot.h \
   jeeps/gpscom.h jeeps/gpsfmt.h jeeps/gpsmath.h jeeps/gpsmem.h \
   jeeps/gpsrqst.h
 garmin_tables.o: garmin_tables.cc defs.h config.h zlib/zlib.h \
-  zlib/zconf.h cet.h inifile.h gbfile.h session.h src/core/datetime.h \
-  src/core/optional.h garmin_tables.h jeeps/gpsmath.h jeeps/gpsport.h \
-  src/core/logging.h garmin_icon_tables.h
+  zlib/zconf.h formspec.h inifile.h gbfile.h session.h \
+  src/core/datetime.h src/core/optional.h garmin_tables.h \
+  jeeps/gpsmath.h jeeps/gpsport.h src/core/logging.h \
+  garmin_icon_tables.h
 garmin_txt.o: garmin_txt.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
-  cet.h inifile.h gbfile.h session.h src/core/datetime.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
   src/core/optional.h csv_util.h garmin_fs.h jeeps/gps.h jeeps/../defs.h \
   jeeps/gpsport.h jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h \
   jeeps/gpsutil.h jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h \
   jeeps/gpsfmt.h jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h \
   garmin_tables.h src/core/textstream.h src/core/file.h strptime.h
-garmin_xt.o: garmin_xt.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
-gbfile.o: gbfile.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+garmin_xt.o: garmin_xt.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h
+gbfile.o: gbfile.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  src/core/logging.h
-gbser.o: gbser.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+  src/core/logging.h cet.h
+gbser.o: gbser.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   gbser.h gbser_private.h
 gbser_posix.o: gbser_posix.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
-  cet.h inifile.h gbfile.h session.h src/core/datetime.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
   src/core/optional.h gbser.h gbser_private.h
-gdb.o: gdb.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h cet_util.h \
-  garmin_fs.h jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h \
+gdb.o: gdb.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
+  cet_util.h garmin_fs.h jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h \
   jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
   jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
   jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h garmin_tables.h \
   grtcirc.h
-geo.o: geo.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  src/core/file.h
-geojson.o: geojson.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+geo.o: geo.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   src/core/file.h
-ggv_bin.o: ggv_bin.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+geojson.o: geojson.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  ggv_bin.h format.h
-ggv_log.o: ggv_log.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+  src/core/file.h
+ggv_bin.o: ggv_bin.cc ggv_bin.h defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h format.h
+ggv_log.o: ggv_log.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   grtcirc.h
-ggv_ovl.o: ggv_ovl.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+ggv_ovl.o: ggv_ovl.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   grtcirc.h
-globals.o: globals.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+globals.o: globals.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   gbversion.h
 globalsat_sport.o: globalsat_sport.cc defs.h config.h zlib/zlib.h \
-  zlib/zconf.h cet.h inifile.h gbfile.h session.h src/core/datetime.h \
-  src/core/optional.h gbser.h
-glogbook.o: glogbook.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  src/core/file.h xmlgeneric.h
-gnav_trl.o: gnav_trl.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
-googledir.o: googledir.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  xmlgeneric.h
-gopal.o: gopal.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+  zlib/zconf.h formspec.h inifile.h gbfile.h session.h \
+  src/core/datetime.h src/core/optional.h gbser.h
+glogbook.o: glogbook.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h src/core/file.h xmlgeneric.h
+gnav_trl.o: gnav_trl.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h
+googledir.o: googledir.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h xmlgeneric.h
+gopal.o: gopal.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   cet_util.h csv_util.h grtcirc.h jeeps/gpsmath.h jeeps/gpsport.h \
   strptime.h
-gpssim.o: gpssim.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+gpssim.o: gpssim.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
-gpsutil.o: gpsutil.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+gpsutil.o: gpsutil.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   cet_util.h magellan.h
-gpx.o: gpx.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h gpx.h \
-  format.h src/core/file.h src/core/xmlstreamwriter.h src/core/xmltag.h \
-  garmin_fs.h jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h \
-  jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
-  jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
-  jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h garmin_tables.h \
-  src/core/logging.h
-grtcirc.o: grtcirc.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+gpx.o: gpx.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
+  gpx.h format.h src/core/file.h src/core/xmlstreamwriter.h \
+  src/core/xmltag.h garmin_fs.h jeeps/gps.h jeeps/../defs.h \
+  jeeps/gpsport.h jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h \
+  jeeps/gpsutil.h jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h \
+  jeeps/gpsfmt.h jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h \
+  garmin_tables.h src/core/logging.h
+grtcirc.o: grtcirc.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   grtcirc.h
-gtm.o: gtm.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h \
+gtm.o: gtm.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   jeeps/gpsmath.h jeeps/gpsport.h
-gtrnctr.o: gtrnctr.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+gtrnctr.o: gtrnctr.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   xmlgeneric.h
-height.o: height.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+height.o: height.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   height.h filter.h heightgrid.h
-hiketech.o: hiketech.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  src/core/xmlstreamwriter.h xmlgeneric.h
-holux.o: holux.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+hiketech.o: hiketech.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h src/core/xmlstreamwriter.h xmlgeneric.h
+holux.o: holux.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   holux.h
-html.o: html.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h \
+html.o: html.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   jeeps/gpsmath.h jeeps/gpsport.h src/core/xmltag.h
 humminbird.o: humminbird.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
-  cet.h inifile.h gbfile.h session.h src/core/datetime.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
   src/core/optional.h
-igc.o: igc.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h cet_util.h
-ignrando.o: ignrando.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+igc.o: igc.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
+  cet_util.h
+ignrando.o: ignrando.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h xmlgeneric.h
+igo8.o: igo8.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
+ik3d.o: ik3d.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   xmlgeneric.h
-igo8.o: igo8.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h
-ik3d.o: ik3d.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  xmlgeneric.h
-inifile.o: inifile.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+inifile.o: inifile.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   src/core/file.h
 internal_styles.o: internal_styles.cc defs.h config.h zlib/zlib.h \
-  zlib/zconf.h cet.h inifile.h gbfile.h session.h src/core/datetime.h \
-  src/core/optional.h
+  zlib/zconf.h formspec.h inifile.h gbfile.h session.h \
+  src/core/datetime.h src/core/optional.h
 interpolate.o: interpolate.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
-  cet.h inifile.h gbfile.h session.h src/core/datetime.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
   src/core/optional.h interpolate.h filter.h grtcirc.h
-itracku.o: itracku.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+itracku.o: itracku.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   gbser.h
 jeeps/gpsapp.o: jeeps/gpsapp.cc jeeps/gps.h jeeps/../defs.h config.h \
-  zlib/zlib.h zlib/zconf.h cet.h inifile.h gbfile.h defs.h session.h \
-  src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
+  zlib/zlib.h zlib/zconf.h formspec.h inifile.h gbfile.h defs.h \
+  session.h src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
   jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
   jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
   jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/garminusb.h \
   jeeps/gpsserial.h jeeps/gpsusbint.h
 jeeps/gpscom.o: jeeps/gpscom.cc jeeps/gps.h jeeps/../defs.h config.h \
-  zlib/zlib.h zlib/zconf.h cet.h inifile.h gbfile.h defs.h session.h \
-  src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
+  zlib/zlib.h zlib/zconf.h formspec.h inifile.h gbfile.h defs.h \
+  session.h src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
   jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
   jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
   jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h
 jeeps/gpsdevice.o: jeeps/gpsdevice.cc jeeps/gps.h jeeps/../defs.h \
-  config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h gbfile.h defs.h \
+  config.h zlib/zlib.h zlib/zconf.h formspec.h inifile.h gbfile.h defs.h \
   session.h src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
   jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
   jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
   jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsserial.h
 jeeps/gpsdevice_ser.o: jeeps/gpsdevice_ser.cc jeeps/gps.h jeeps/../defs.h \
-  config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h gbfile.h defs.h \
+  config.h zlib/zlib.h zlib/zconf.h formspec.h inifile.h gbfile.h defs.h \
   session.h src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
   jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
   jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
   jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsserial.h
 jeeps/gpsdevice_usb.o: jeeps/gpsdevice_usb.cc jeeps/gps.h jeeps/../defs.h \
-  config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h gbfile.h defs.h \
+  config.h zlib/zlib.h zlib/zconf.h formspec.h inifile.h gbfile.h defs.h \
   session.h src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
   jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
   jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
   jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/garminusb.h \
   jeeps/gpsusbcommon.h jeeps/gpsusbint.h
 jeeps/gpslibusb.o: jeeps/gpslibusb.cc config.h mac/libusb/libusb.h \
-  jeeps/../defs.h zlib/zlib.h zlib/zconf.h cet.h inifile.h gbfile.h \
+  jeeps/../defs.h zlib/zlib.h zlib/zconf.h formspec.h inifile.h gbfile.h \
   defs.h session.h src/core/datetime.h src/core/optional.h \
   jeeps/garminusb.h jeeps/gpsdevice.h jeeps/gps.h jeeps/gpsport.h \
   jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h jeeps/gpsapp.h \
@@ -706,50 +722,50 @@ jeeps/gpslibusb.o: jeeps/gpslibusb.cc config.h mac/libusb/libusb.h \
   jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsusbcommon.h \
   jeeps/../garmin_device_xml.h
 jeeps/gpsmath.o: jeeps/gpsmath.cc jeeps/gps.h jeeps/../defs.h config.h \
-  zlib/zlib.h zlib/zconf.h cet.h inifile.h gbfile.h defs.h session.h \
-  src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
+  zlib/zlib.h zlib/zconf.h formspec.h inifile.h gbfile.h defs.h \
+  session.h src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
   jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
   jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
   jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsdatum.h
 jeeps/gpsmem.o: jeeps/gpsmem.cc jeeps/gps.h jeeps/../defs.h config.h \
-  zlib/zlib.h zlib/zconf.h cet.h inifile.h gbfile.h defs.h session.h \
-  src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
+  zlib/zlib.h zlib/zconf.h formspec.h inifile.h gbfile.h defs.h \
+  session.h src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
   jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
   jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
   jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h
 jeeps/gpsprot.o: jeeps/gpsprot.cc jeeps/gps.h jeeps/../defs.h config.h \
-  zlib/zlib.h zlib/zconf.h cet.h inifile.h gbfile.h defs.h session.h \
-  src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
+  zlib/zlib.h zlib/zconf.h formspec.h inifile.h gbfile.h defs.h \
+  session.h src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
   jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
   jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
   jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h
 jeeps/gpsread.o: jeeps/gpsread.cc jeeps/gps.h jeeps/../defs.h config.h \
-  zlib/zlib.h zlib/zconf.h cet.h inifile.h gbfile.h defs.h session.h \
-  src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
+  zlib/zlib.h zlib/zconf.h formspec.h inifile.h gbfile.h defs.h \
+  session.h src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
   jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
   jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
   jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsserial.h
 jeeps/gpsrqst.o: jeeps/gpsrqst.cc jeeps/gps.h jeeps/../defs.h config.h \
-  zlib/zlib.h zlib/zconf.h cet.h inifile.h gbfile.h defs.h session.h \
-  src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
+  zlib/zlib.h zlib/zconf.h formspec.h inifile.h gbfile.h defs.h \
+  session.h src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
   jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
   jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
   jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h
 jeeps/gpssend.o: jeeps/gpssend.cc jeeps/gps.h jeeps/../defs.h config.h \
-  zlib/zlib.h zlib/zconf.h cet.h inifile.h gbfile.h defs.h session.h \
-  src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
+  zlib/zlib.h zlib/zconf.h formspec.h inifile.h gbfile.h defs.h \
+  session.h src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
   jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
   jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
   jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsserial.h
 jeeps/gpsserial.o: jeeps/gpsserial.cc jeeps/gps.h jeeps/../defs.h \
-  config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h gbfile.h defs.h \
+  config.h zlib/zlib.h zlib/zconf.h formspec.h inifile.h gbfile.h defs.h \
   session.h src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
   jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
   jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
   jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/../gbser.h \
   jeeps/gpsserial.h gbser_posix.h
 jeeps/gpsusbcommon.o: jeeps/gpsusbcommon.cc jeeps/gps.h jeeps/../defs.h \
-  config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h gbfile.h defs.h \
+  config.h zlib/zlib.h zlib/zconf.h formspec.h inifile.h gbfile.h defs.h \
   session.h src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
   jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
   jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
@@ -757,304 +773,327 @@ jeeps/gpsusbcommon.o: jeeps/gpsusbcommon.cc jeeps/gps.h jeeps/../defs.h \
   jeeps/gpsusbcommon.h
 jeeps/gpsusbread.o: jeeps/gpsusbread.cc jeeps/garminusb.h \
   jeeps/gpsdevice.h jeeps/gps.h jeeps/../defs.h config.h zlib/zlib.h \
-  zlib/zconf.h cet.h inifile.h gbfile.h defs.h session.h \
+  zlib/zconf.h formspec.h inifile.h gbfile.h defs.h session.h \
   src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
   jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h jeeps/gpsapp.h \
   jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h jeeps/gpsmath.h \
   jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsusbint.h
 jeeps/gpsusbsend.o: jeeps/gpsusbsend.cc jeeps/gps.h jeeps/../defs.h \
-  config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h gbfile.h defs.h \
+  config.h zlib/zlib.h zlib/zconf.h formspec.h inifile.h gbfile.h defs.h \
   session.h src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
   jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
   jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
   jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/garminusb.h \
   jeeps/gpsusbint.h
 jeeps/jgpsutil.o: jeeps/jgpsutil.cc jeeps/gps.h jeeps/../defs.h config.h \
-  zlib/zlib.h zlib/zconf.h cet.h inifile.h gbfile.h defs.h session.h \
-  src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
+  zlib/zlib.h zlib/zconf.h formspec.h inifile.h gbfile.h defs.h \
+  session.h src/core/datetime.h src/core/optional.h jeeps/gpsport.h \
   jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
   jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
   jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h
-jogmap.o: jogmap.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+jogmap.o: jogmap.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   garmin_tables.h jeeps/gpsmath.h jeeps/gpsport.h xmlgeneric.h
-jtr.o: jtr.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h csv_util.h
-kml.o: kml.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h grtcirc.h \
-  src/core/file.h src/core/logging.h src/core/xmlstreamwriter.h \
-  src/core/xmltag.h units.h xmlgeneric.h
-lmx.o: lmx.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h \
+jtr.o: jtr.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
+  csv_util.h
+kml.o: kml.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
+  grtcirc.h src/core/file.h src/core/logging.h \
+  src/core/xmlstreamwriter.h src/core/xmltag.h units.h xmlgeneric.h
+lmx.o: lmx.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   xmlgeneric.h
-lowranceusr.o: lowranceusr.cc src/core/logging.h defs.h config.h \
-  zlib/zlib.h zlib/zconf.h cet.h inifile.h gbfile.h session.h \
-  src/core/datetime.h src/core/optional.h
-maggeo.o: maggeo.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+lowranceusr.o: lowranceusr.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h src/core/logging.h
+maggeo.o: maggeo.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   csv_util.h magellan.h xmlgeneric.h
-magproto.o: magproto.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  explorist_ini.h format.h gbser.h magellan.h vecs.h gpx.h \
-  src/core/file.h src/core/xmlstreamwriter.h src/core/xmltag.h \
-  legacyformat.h
-main.o: main.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h cet_util.h \
-  csv_util.h filter.h filter_vecs.h arcdist.h bend.h discard.h \
-  duplicate.h height.h interpolate.h nukedata.h polygon.h position.h \
-  radius.h reverse_route.h smplrout.h sort.h stackfilter.h swapdata.h \
-  trackfilter.h transform.h validate.h format.h src/core/file.h \
-  src/core/usasciicodec.h vecs.h gpx.h src/core/xmlstreamwriter.h \
-  src/core/xmltag.h legacyformat.h
-mapasia.o: mapasia.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+magproto.o: magproto.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h explorist_ini.h format.h gbser.h magellan.h vecs.h \
+  ggv_bin.h gpx.h src/core/file.h src/core/xmlstreamwriter.h \
+  src/core/xmltag.h legacyformat.h mynav.h xcsv.h garmin_fs.h \
+  jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h jeeps/gpsdevice.h \
+  jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h jeeps/gpsapp.h \
+  jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h jeeps/gpsmath.h \
+  jeeps/gpsmem.h jeeps/gpsrqst.h src/core/textstream.h
+main.o: main.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
+  cet_util.h csv_util.h filter.h filter_vecs.h arcdist.h bend.h \
+  discard.h duplicate.h height.h heightgrid.h interpolate.h nukedata.h \
+  polygon.h position.h radius.h reverse_route.h smplrout.h sort.h \
+  stackfilter.h swapdata.h trackfilter.h transform.h validate.h format.h \
+  src/core/file.h src/core/usasciicodec.h vecs.h ggv_bin.h gpx.h \
+  src/core/xmlstreamwriter.h src/core/xmltag.h legacyformat.h mynav.h \
+  xcsv.h garmin_fs.h jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h \
+  jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
+  jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
+  jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h src/core/textstream.h
+mapasia.o: mapasia.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
 mapbar_track.o: mapbar_track.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
-  cet.h inifile.h gbfile.h session.h src/core/datetime.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
   src/core/optional.h
-mapfactor.o: mapfactor.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  src/core/file.h src/core/xmlstreamwriter.h
-mapsend.o: mapsend.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+mapfactor.o: mapfactor.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h src/core/file.h src/core/xmlstreamwriter.h
+mapsend.o: mapsend.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   mapsend.h magellan.h
-mapsource.o: mapsource.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+mapsource.o: mapsource.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h garmin_tables.h jeeps/gpsmath.h jeeps/gpsport.h
+mkshort.o: mkshort.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  garmin_tables.h jeeps/gpsmath.h jeeps/gpsport.h
-mkshort.o: mkshort.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+  cet.h
+mmo.o: mmo.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
-mmo.o: mmo.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h
-mtk_locus.o: mtk_locus.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  gbser.h
+mtk_locus.o: mtk_locus.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h gbser.h
 mtk_logger.o: mtk_logger.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
-  cet.h inifile.h gbfile.h session.h src/core/datetime.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
   src/core/optional.h gbser.h
-mynav.o: mynav.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  mynav.h format.h
-navicache.o: navicache.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  cet_util.h src/core/file.h
-naviguide.o: naviguide.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  csv_util.h jeeps/gpsmath.h jeeps/gpsport.h
-navilink.o: navilink.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  gbser.h jeeps/gpsmath.h jeeps/gpsport.h navilink.h
-navitel.o: navitel.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+mynav.o: mynav.cc src/core/textstream.h src/core/file.h defs.h config.h \
+  zlib/zlib.h zlib/zconf.h formspec.h inifile.h gbfile.h session.h \
+  src/core/datetime.h src/core/optional.h mynav.h format.h
+navicache.o: navicache.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h cet_util.h src/core/file.h
+naviguide.o: naviguide.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h csv_util.h jeeps/gpsmath.h jeeps/gpsport.h
+navilink.o: navilink.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h gbser.h jeeps/gpsmath.h jeeps/gpsport.h navilink.h
+navitel.o: navitel.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   jeeps/gpsmath.h jeeps/gpsport.h
 netstumbler.o: netstumbler.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
-  cet.h inifile.h gbfile.h session.h src/core/datetime.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
   src/core/optional.h cet_util.h csv_util.h
-nmea.o: nmea.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h cet_util.h \
-  gbser.h jeeps/gpsmath.h jeeps/gpsport.h src/core/logging.h strptime.h
-nmn4.o: nmn4.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h cet_util.h \
-  csv_util.h
-nukedata.o: nukedata.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+nmea.o: nmea.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
+  cet_util.h gbser.h jeeps/gpsmath.h jeeps/gpsport.h src/core/logging.h \
+  strptime.h
+nmn4.o: nmn4.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
+  cet_util.h csv_util.h
+nukedata.o: nukedata.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h nukedata.h filter.h
+osm.o: osm.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  nukedata.h filter.h
-osm.o: osm.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h \
   xmlgeneric.h
-ozi.o: ozi.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h csv_util.h \
-  jeeps/gpsmath.h jeeps/gpsport.h src/core/textstream.h src/core/file.h
-parse.o: parse.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+ozi.o: ozi.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
+  csv_util.h jeeps/gpsmath.h jeeps/gpsport.h src/core/textstream.h \
+  src/core/file.h
+parse.o: parse.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   jeeps/gpsmath.h jeeps/gpsport.h
-pcx.o: pcx.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h cet_util.h \
-  csv_util.h garmin_tables.h
+pcx.o: pcx.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
+  cet_util.h csv_util.h garmin_tables.h
 pocketfms_bc.o: pocketfms_bc.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
-  cet.h inifile.h gbfile.h session.h src/core/datetime.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
   src/core/optional.h
 pocketfms_fp.o: pocketfms_fp.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
-  cet.h inifile.h gbfile.h session.h src/core/datetime.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
   src/core/optional.h xmlgeneric.h
 pocketfms_wp.o: pocketfms_wp.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
-  cet.h inifile.h gbfile.h session.h src/core/datetime.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
   src/core/optional.h csv_util.h
-polygon.o: polygon.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+polygon.o: polygon.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   polygon.h filter.h
-position.o: position.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  grtcirc.h position.h filter.h
-psitrex.o: psitrex.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+position.o: position.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h grtcirc.h position.h filter.h
+psitrex.o: psitrex.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   garmin_tables.h
-radius.o: radius.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+radius.o: radius.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   radius.h filter.h grtcirc.h
-random.o: random.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+random.o: random.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   garmin_fs.h jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h \
   jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
   jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
   jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h
-raymarine.o: raymarine.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  csv_util.h
+raymarine.o: raymarine.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h csv_util.h
 reverse_route.o: reverse_route.cc defs.h config.h zlib/zlib.h \
-  zlib/zconf.h cet.h inifile.h gbfile.h session.h src/core/datetime.h \
-  src/core/optional.h reverse_route.h filter.h
-rgbcolors.o: rgbcolors.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
-route.o: route.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+  zlib/zconf.h formspec.h inifile.h gbfile.h session.h \
+  src/core/datetime.h src/core/optional.h reverse_route.h filter.h
+rgbcolors.o: rgbcolors.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h
+route.o: route.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   grtcirc.h
-saroute.o: saroute.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+saroute.o: saroute.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   grtcirc.h
-sbn.o: sbn.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h navilink.h
-sbp.o: sbp.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h navilink.h
-session.o: session.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+sbn.o: sbn.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
+  navilink.h
+sbp.o: sbp.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
+  navilink.h
+session.o: session.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
-shape.o: shape.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+shape.o: shape.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   shapelib/shapefil.h
 shapelib/dbfopen.o: shapelib/dbfopen.c shapelib/shapefil.h
 shapelib/safileio.o: shapelib/safileio.c shapelib/shapefil.h
 shapelib/shpopen.o: shapelib/shpopen.c shapelib/shapefil.h
-skyforce.o: skyforce.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
-skytraq.o: skytraq.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+skyforce.o: skyforce.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h
+skytraq.o: skytraq.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   gbser.h
-smplrout.o: smplrout.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  grtcirc.h smplrout.h filter.h
-sort.o: sort.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h sort.h \
-  filter.h
-src/core/textstream.o: src/core/textstream.cc src/core/textstream.h \
-  src/core/file.h defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
+smplrout.o: smplrout.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h grtcirc.h smplrout.h filter.h
+sort.o: sort.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
+  sort.h filter.h
+src/core/textstream.o: src/core/textstream.cc defs.h config.h zlib/zlib.h \
+  zlib/zconf.h formspec.h inifile.h gbfile.h session.h \
+  src/core/datetime.h src/core/optional.h src/core/textstream.h \
+  src/core/file.h
 src/core/usasciicodec.o: src/core/usasciicodec.cc src/core/usasciicodec.h
 src/core/xmlstreamwriter.o: src/core/xmlstreamwriter.cc \
   src/core/xmlstreamwriter.h
 stackfilter.o: stackfilter.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
-  cet.h inifile.h gbfile.h session.h src/core/datetime.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
   src/core/optional.h stackfilter.h filter.h
-stmsdf.o: stmsdf.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+stmsdf.o: stmsdf.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   cet_util.h csv_util.h grtcirc.h jeeps/gpsmath.h jeeps/gpsport.h \
   src/core/logging.h
-stmwpp.o: stmwpp.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+stmwpp.o: stmwpp.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   csv_util.h cet_util.h
 strptime.o: strptime.c config.h strptime.h
-subrip.o: subrip.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+subrip.o: subrip.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
-swapdata.o: swapdata.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  swapdata.h filter.h
-tef_xml.o: tef_xml.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+swapdata.o: swapdata.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h swapdata.h filter.h
+tef_xml.o: tef_xml.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   xmlgeneric.h
-teletype.o: teletype.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
-text.o: text.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h \
+teletype.o: teletype.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h
+text.o: text.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   jeeps/gpsmath.h jeeps/gpsport.h src/core/xmltag.h
-tiger.o: tiger.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+tiger.o: tiger.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   cet_util.h csv_util.h
-tmpro.o: tmpro.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+tmpro.o: tmpro.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   cet_util.h csv_util.h
-tomtom.o: tomtom.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+tomtom.o: tomtom.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
-tpg.o: tpg.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h \
+tpg.o: tpg.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   jeeps/gpsmath.h jeeps/gpsport.h
-tpo.o: tpo.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h \
+tpo.o: tpo.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   jeeps/gpsmath.h jeeps/gpsport.h
 trackfilter.o: trackfilter.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
-  cet.h inifile.h gbfile.h session.h src/core/datetime.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
   src/core/optional.h trackfilter.h filter.h grtcirc.h
-transform.o: transform.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  transform.h filter.h
-unicsv.o: unicsv.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+transform.o: transform.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h transform.h filter.h
+unicsv.o: unicsv.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   csv_util.h garmin_fs.h jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h \
   jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
   jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
   jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h garmin_tables.h \
   src/core/logging.h src/core/textstream.h src/core/file.h
-units.o: units.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+units.o: units.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   units.h
-util.o: util.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  src/core/xmltag.h
+util.o: util.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
+  cet.h src/core/xmltag.h
 util_crc.o: util_crc.cc
-v900.o: v900.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h
-validate.o: validate.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+v900.o: v900.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
+validate.o: validate.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h validate.h filter.h
+vcf.o: vcf.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  validate.h filter.h
-vcf.o: vcf.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h \
   jeeps/gpsmath.h jeeps/gpsport.h
-vecs.o: vecs.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h vecs.h \
-  format.h gpx.h src/core/file.h src/core/xmlstreamwriter.h \
-  src/core/xmltag.h legacyformat.h gbversion.h src/core/logging.h xcsv.h \
-  ggv_bin.h mynav.h
-vidaone.o: vidaone.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+vecs.o: vecs.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
+  vecs.h format.h ggv_bin.h gpx.h src/core/file.h \
+  src/core/xmlstreamwriter.h src/core/xmltag.h legacyformat.h mynav.h \
+  xcsv.h garmin_fs.h jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h \
+  jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
+  jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
+  jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h src/core/textstream.h \
+  gbversion.h src/core/logging.h
+vidaone.o: vidaone.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
-vitosmt.o: vitosmt.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+vitosmt.o: vitosmt.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   grtcirc.h
-vitovtt.o: vitovtt.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+vitovtt.o: vitovtt.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
-vpl.o: vpl.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h
-waypt.o: waypt.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+vpl.o: vpl.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h
+waypt.o: waypt.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   garmin_fs.h jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h \
   jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
   jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
   jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h grtcirc.h \
   src/core/logging.h
-wbt-200.o: wbt-200.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+wbt-200.o: wbt-200.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   gbser.h grtcirc.h
-wfff_xml.o: wfff_xml.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
-  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  xmlgeneric.h
+wfff_xml.o: wfff_xml.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
+  src/core/optional.h xmlgeneric.h
 wintec_tes.o: wintec_tes.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
-  cet.h inifile.h gbfile.h session.h src/core/datetime.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
   src/core/optional.h
-xcsv.o: xcsv.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h csv_util.h \
-  garmin_fs.h jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h \
+xcsv.o: xcsv.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
+  csv_util.h garmin_fs.h jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h \
   jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
   jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
   jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h grtcirc.h \
-  src/core/file.h src/core/logging.h strptime.h xcsv.h xcsv_tokens.gperf
+  src/core/logging.h src/core/textstream.h src/core/file.h strptime.h \
+  xcsv.h format.h xcsv_tokens.gperf
 xmlgeneric.o: xmlgeneric.cc defs.h config.h zlib/zlib.h zlib/zconf.h \
-  cet.h inifile.h gbfile.h session.h src/core/datetime.h \
+  formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
   src/core/optional.h cet_util.h src/core/file.h xmlgeneric.h
-xmltag.o: xmltag.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
+xmltag.o: xmltag.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
   inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   src/core/xmltag.h
-xol.o: xol.cc defs.h config.h zlib/zlib.h zlib/zconf.h cet.h inifile.h \
-  gbfile.h session.h src/core/datetime.h src/core/optional.h \
+xol.o: xol.cc defs.h config.h zlib/zlib.h zlib/zconf.h formspec.h \
+  inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
   garmin_tables.h jeeps/gpsmath.h jeeps/gpsport.h src/core/file.h \
   src/core/xmlstreamwriter.h xmlgeneric.h
-yahoo.o: yahoo.cc yahoo.h defs.h config.h zlib/zlib.h zlib/zconf.h cet.h \
 inifile.h gbfile.h session.h src/core/datetime.h src/core/optional.h \
-  xmlgeneric.h
+yahoo.o: yahoo.cc defs.h config.h zlib/zlib.h zlib/zconf.h config.h \
formspec.h inifile.h gbfile.h session.h src/core/datetime.h \
src/core/optional.h yahoo.h format.h xmlgeneric.h
 zlib/adler32.o: zlib/adler32.c zlib/zutil.h zlib/zlib.h zlib/zconf.h \
   config.h
 zlib/compress.o: zlib/compress.c zlib/zlib.h zlib/zconf.h config.h
diff --git a/an1.cc b/an1.cc
index 18c7aa867e75847e6d796738135310e26cf45fcf..b773f0f61576d5e4a208d354848631478a2651d1 100644 (file)
--- a/an1.cc
+++ b/an1.cc
 
  */
 
+#include <cstdio>               // for sprintf, SEEK_CUR
+#include <cstdint>              // for int32_t
+#include <cstdlib>              // for atoi, atof
+#include <cstring>              // for strlen, strchr, memcpy, strstr
+
+#include <QtCore/QString>       // for QString
+#include <QtCore/QVector>       // for QVector
+
 #include "defs.h"
-#include <cstdio> // sprintf
-#include <cstdlib> // atof
+#include "formspec.h"           // for FsChainAdd, FsChainFind, FormatSpecificData, kFsAn1L, kFsAn1V, kFsAn1W
+#include "gbfile.h"             // for gbfgetint32, gbfputint32, gbfputint16, gbfgetint16, gbfile, gbfputs, gbfgetc, gbfputc, gbfclose, gbfopen_le, gbfgetdbl, gbfputdbl, gbfread, gbfseek
+#include "src/core/datetime.h"  // for DateTime
+
 
 #define MYNAME "an1"
 
@@ -114,7 +124,7 @@ struct guid_t {
 static char*
 ReadString(gbfile* f, short len)
 {
-  char* result = (char*)xcalloc(1, len + 1);
+  auto* result = (char*)xcalloc(1, len + 1);
   if (len) {
     gbfread(result, 1, len, f);
   }
@@ -129,10 +139,10 @@ static void
 ReadGuid(gbfile* f, guid_t* guid)
 {
   guid->l = ReadLong(f);
-  for (unsigned short &i : guid->s) {
+  for (unsigned shorti : guid->s) {
     i = ReadShort(f);
   }
-  for (unsigned char &i : guid->c) {
+  for (unsigned chari : guid->c) {
     i = ReadChar(f);
   }
 }
@@ -169,176 +179,129 @@ EncodeOrd(double ord)
 }
 
 struct an1_symbol_record {
-  short hotspotxhi;
-  long hotspoty;
-  long unk1;
-  guid_t guid;
-  char* name;
+  short hotspotxhi{0};
+  long hotspoty{0};
+  long unk1{0};
+  guid_t guid{};
+  char* name{nullptr};
 };
 
-struct an1_waypoint_record {
-  format_specific_data fs;
-  short magic;
-  long unk1;
-  long lon;
-  long lat;
-  short type;
-  long height;
-  long width;
-  short unk2;
-  short unk3;
-  short serial;
-  short unk4;
-  unsigned char create_zoom;
-  unsigned char visible_zoom;
-  short unk5;
-  double radius; /* in km */
-  char* name;
-  char* fontname;
-  guid_t guid;
-  long fontcolor;
-  long fontstyle;
-  long fontsize;
-  long outlineweight;
-  long outlinecolor;
-  long outlineflags;
-  long fillcolor;
-  long unk6;
-  long fillflags;
+struct an1_waypoint_record : FormatSpecificData {
+  an1_waypoint_record() : FormatSpecificData(kFsAn1W) {}
+private:
+  an1_waypoint_record(const an1_waypoint_record&) = default;
+public:
+  an1_waypoint_record& operator=(const an1_waypoint_record&) = delete;
+  an1_waypoint_record(an1_waypoint_record&&) = delete;
+  an1_waypoint_record& operator=(an1_waypoint_record&&) = delete;
+  ~an1_waypoint_record() override
+  {
+    xfree(name);
+    xfree(fontname);
+    xfree(url);
+    xfree(comment);
+    xfree(image_name);
+  }
 
-  /* Added in SA2006/Topo 6.0 */
-  short unk6_1;
-  char* url;
-  char* comment;
-  long creation_time;
-  long modification_time;
-  char* image_name;
-};
+  an1_waypoint_record* clone() const override
+  {
+    auto* copy = new an1_waypoint_record(*this);
+    copy->name = xstrdup(name);
+    copy->fontname = xstrdup(fontname);
+    copy->url = xstrdup(url);
+    copy->comment = xstrdup(comment);
+    copy->image_name = xstrdup(image_name);
+    return copy;
+  }
 
-struct an1_vertex_record {
-  format_specific_data fs;
-  short magic;
-  long unk0;
-  long lon;
-  long lat;
-  short unk1;
-};
+  short magic{0};
+  long unk1{0};
+  long lon{0};
+  long lat{0};
+  short type{0};
+  long height{0};
+  long width{0};
+  short unk2{0};
+  short unk3{0};
+  short serial{0};
+  short unk4{0};
+  unsigned char create_zoom{0};
+  unsigned char visible_zoom{0};
+  short unk5{0};
+  double radius{0.0}; /* in km */
+  char* name{nullptr};
+  char* fontname{nullptr};
+  guid_t guid{};
+  long fontcolor{0};
+  long fontstyle{0};
+  long fontsize{0};
+  long outlineweight{0};
+  long outlinecolor{0};
+  long outlineflags{0};
+  long fillcolor{0};
+  long unk6{0};
+  long fillflags{0};
 
-struct an1_line_record {
-  format_specific_data fs;
-  long roadtype;
-  short serial;
-  long unk2;
-  short unk3;
-  short type;
-  long unk4;
-  char* name;
-  long lineweight;
-  long linestyle;
-  long linecolor;
-  long opacity;
-  long polyfillcolor;
-  long unk6;
-  long unk7;
-  short unk8;
-  long pointcount;
+  /* Added in SA2006/Topo 6.0 */
+  short unk6_1{0};
+  char* url{nullptr};
+  char* comment{nullptr};
+  long creation_time{0};
+  long modification_time{0};
+  char* image_name{nullptr};
 };
 
-static an1_waypoint_record* Alloc_AN1_Waypoint();
-
-static void Destroy_AN1_Waypoint(void* vwpt)
-{
-
-  auto* wpt = (an1_waypoint_record*)vwpt;
-  xfree(wpt->name);
-  xfree(wpt->fontname);
-
-  if (wpt->url) {
-    xfree(wpt->url);
-  }
-  if (wpt->comment) {
-    xfree(wpt->comment);
-  }
-  if (wpt->image_name) {
-    xfree(wpt->image_name);
+struct an1_vertex_record : FormatSpecificData {
+  an1_vertex_record() : FormatSpecificData(kFsAn1V) {}
+  an1_vertex_record* clone() const override
+  {
+    return new an1_vertex_record(*this);
   }
-  xfree(vwpt);
-}
-
-static void Copy_AN1_Waypoint(void** vdwpt, void* vwpt)
-{
-  auto* wpt = (an1_waypoint_record*)vwpt;
-  an1_waypoint_record* dwpt = Alloc_AN1_Waypoint();
-  memcpy(dwpt, wpt, sizeof(an1_waypoint_record));
-  dwpt->name = xstrdup(wpt->name);
-  dwpt->fontname = xstrdup(wpt->fontname);
-  dwpt->url = xstrdup(wpt->url);
-  dwpt->comment = xstrdup(wpt->comment);
-  dwpt->image_name = xstrdup(wpt->image_name);
-  *vdwpt = (void*)dwpt;
-}
-
-static an1_waypoint_record* Alloc_AN1_Waypoint()
-{
-  auto* result = (an1_waypoint_record*)xcalloc(1, sizeof(an1_waypoint_record));
-  result->fs.type = FS_AN1W;
-  result->fs.copy = Copy_AN1_Waypoint;
-  result->fs.destroy = Destroy_AN1_Waypoint;
-  return result;
-}
 
-static an1_vertex_record* Alloc_AN1_Vertex();
-
-static void Destroy_AN1_Vertex(void* vvertex)
-{
-  xfree(vvertex);
-}
-
-static void Copy_AN1_Vertex(void** vdvert, void* vvert)
-{
-  auto* vert = (an1_vertex_record*)vvert;
-  an1_vertex_record* dvert = Alloc_AN1_Vertex();
-  memcpy(dvert, vert, sizeof(an1_vertex_record));
-  *vdvert = (void*)dvert;
-}
-
-static an1_vertex_record* Alloc_AN1_Vertex()
-{
-  auto* result = (an1_vertex_record*)xcalloc(1, sizeof(an1_vertex_record));
-  result->fs.type = FS_AN1V;
-  result->fs.copy = Copy_AN1_Vertex;
-  result->fs.destroy = Destroy_AN1_Vertex;
-  return result;
-}
-
-
-static an1_line_record* Alloc_AN1_Line();
-
-static void Destroy_AN1_Line(void* vline)
-{
-  auto* line = (an1_line_record*)vline;
-  xfree(line->name);
-  xfree(vline);
-}
+  short magic{0};
+  long unk0{0};
+  long lon{0};
+  long lat{0};
+  short unk1{0};
+};
 
-static void Copy_AN1_Line(void** vdline, void* vline)
-{
-  auto* line = (an1_line_record*)vline;
-  an1_line_record* dline = Alloc_AN1_Line();
-  memcpy(dline, line, sizeof(an1_line_record));
-  dline->name = xstrdup(line->name);
-  *vdline = (void*)dline;
-}
+struct an1_line_record : FormatSpecificData {
+  an1_line_record() : FormatSpecificData(kFsAn1L) {}
+private:
+  an1_line_record(const an1_line_record&) = default;
+public:
+  an1_line_record& operator=(const an1_line_record&) = delete;
+  an1_line_record(an1_line_record&&) = delete;
+  an1_line_record& operator=(an1_line_record&&) = delete;
+  ~an1_line_record() override
+  {
+    xfree(name);
+  }
 
-static an1_line_record* Alloc_AN1_Line()
-{
-  auto* result = (an1_line_record*)xcalloc(1, sizeof(an1_line_record));
-  result->fs.type = FS_AN1L;
-  result->fs.copy = Copy_AN1_Line;
-  result->fs.destroy = Destroy_AN1_Line;
-  return result;
-}
+  an1_line_record* clone() const override
+  {
+    auto* copy = new an1_line_record(*this);
+    copy->name = xstrdup(name);
+    return copy;
+  }
 
+  long roadtype{0};
+  short serial{0};
+  long unk2{0};
+  short unk3{0};
+  short type{0};
+  long unk4{0};
+  char* name{nullptr};
+  long lineweight{0};
+  long linestyle{0};
+  long linecolor{0};
+  long opacity{0};
+  long polyfillcolor{0};
+  long unk6{0};
+  long unk7{0};
+  short unk8{0};
+  long pointcount{0};
+};
 
 static void Destroy_AN1_Symbol(an1_symbol_record* symbol)
 {
@@ -450,8 +413,8 @@ static void Write_AN1_Waypoint(gbfile* f, an1_waypoint_record* wpt)
   WriteDouble(f, wpt->radius);
 
   short len = strlen(wpt->name) + 1 + 2 + 2 +
-        (wpt->url ? strlen(wpt->url) : 0) + 2 +
-        (wpt->comment ? strlen(wpt->comment) : 0) + 8 + 8;
+              (wpt->url ? strlen(wpt->url) : 0) + 2 +
+              (wpt->comment ? strlen(wpt->comment) : 0) + 8 + 8;
   WriteShort(f, len);
   WriteString(f, wpt->name);
   WriteChar(f, 0);    /* name string terminator */
@@ -656,11 +619,11 @@ static void Write_AN1_Bitmaps(gbfile* f)
 
 static void Read_AN1_Waypoints(gbfile* f)
 {
-  char* icon = nullptr;
+  const char* icon = nullptr;
   ReadShort(f);
   unsigned long count = ReadLong(f);
   for (unsigned long i = 0; i < count; i++) {
-    an1_waypoint_record* rec = Alloc_AN1_Waypoint();
+    auto* rec = new an1_waypoint_record;
     Read_AN1_Waypoint(f, rec);
     auto* wpt_tmp = new Waypoint;
 
@@ -692,7 +655,7 @@ static void Read_AN1_Waypoints(gbfile* f)
       wpt_tmp->icon_descr = icon;
     }
 
-    fs_chain_add(&(wpt_tmp->fs), (format_specific_data*)rec);
+    wpt_tmp->fs.FsChainAdd(rec);
     rec = nullptr;
     waypt_add(wpt_tmp);
   }
@@ -702,19 +665,16 @@ static void
 Write_One_AN1_Waypoint(const Waypoint* wpt)
 {
   an1_waypoint_record* rec;
-  bool local;
-  format_specific_data* fs = fs_chain_find(wpt->fs, FS_AN1W);
 
-  if (fs) {
-    rec = (an1_waypoint_record*)fs;
-    xfree(rec->name);
-    local = false;
+  const auto* source_rec = reinterpret_cast<an1_waypoint_record*>(wpt->fs.FsChainFind(kFsAn1W));
+
+  if (source_rec != nullptr) {
+    rec = source_rec->clone();
     if (opt_zoom) {
       rec->visible_zoom = opt_zoom_num;
     }
   } else {
-    rec = Alloc_AN1_Waypoint();
-    local = true;
+    rec = new an1_waypoint_record;
     rec->magic = 1;
     rec->type = wpt_type_num;
     rec->unk2 = 3;
@@ -733,11 +693,12 @@ Write_One_AN1_Waypoint(const Waypoint* wpt)
     rec->visible_zoom = opt_zoom?opt_zoom_num:10;
     rec->unk6_1 = 1;
   }
+  xfree(rec->name);
   rec->name = xstrdup(wpt->description);
 
   if (!nogc && wpt->gc_data->id) {
     // FIXME: this whole mess should be qstring concatenation
-    char* extra = (char*) xmalloc(25 + wpt->gc_data->placer.length() + wpt->shortname.length());
+    auto* extra = (char*) xmalloc(25 + wpt->gc_data->placer.length() + wpt->shortname.length());
     sprintf(extra, "\r\nBy %s\r\n%s (%1.1f/%1.1f)",
             CSTR(wpt->gc_data->placer),
             CSTRc(wpt->shortname), wpt->gc_data->diff/10.0,
@@ -749,11 +710,11 @@ Write_One_AN1_Waypoint(const Waypoint* wpt)
   if (!nourl && wpt->HasUrlLink()) {
     UrlLink l = wpt->GetUrlLink();
     int len = 7 + l.url_.length();
-    char* extra = (char*)xmalloc(len);
+    auto* extra = (char*)xmalloc(len);
     sprintf(extra, "{URL=%s}", CSTR(l.url_));
     rec->name = xstrappend(rec->name, extra);
     xfree(extra);
-    if(rec->url) {
+    if (rec->url) {
       xfree(rec->url);
     }
     rec->url = xstrdup(l.url_);
@@ -783,9 +744,7 @@ Write_One_AN1_Waypoint(const Waypoint* wpt)
   }
 
   Write_AN1_Waypoint(outfile, rec);
-  if (local) {
-    Destroy_AN1_Waypoint(rec);
-  }
+  delete rec;
 }
 
 static void Write_AN1_Waypoints(gbfile* f)
@@ -800,7 +759,7 @@ static void Read_AN1_Lines(gbfile* f)
   ReadShort(f);
   unsigned long count = ReadLong(f);
   for (unsigned long i = 0; i < count; i++) {
-    an1_line_record* rec = Alloc_AN1_Line();
+    auto* rec = new an1_line_record;
     Read_AN1_Line(f, rec);
     /* create route rec */
     auto* rte_head = new route_head;
@@ -815,10 +774,10 @@ static void Read_AN1_Lines(gbfile* f)
       rte_head->line_width = rec->lineweight;
     }
     rte_head->rte_name = rec->name;
-    fs_chain_add(&rte_head->fs, (format_specific_data*)rec);
+    rte_head->fs.FsChainAdd(rec);
     route_add_head(rte_head);
     for (unsigned long j = 0; j < (unsigned) rec->pointcount; j++) {
-      an1_vertex_record* vert = Alloc_AN1_Vertex();
+      auto* vert = new an1_vertex_record;
       Read_AN1_Vertex(f, vert);
 
       /* create route point */
@@ -826,8 +785,7 @@ static void Read_AN1_Lines(gbfile* f)
       wpt_tmp->latitude = DecodeOrd(vert->lat);
       wpt_tmp->longitude = -DecodeOrd(vert->lon);
       wpt_tmp->shortname = QString::asprintf("\\%5.5lx", rtserial++);
-      fs_chain_add(&wpt_tmp->fs,
-                   (format_specific_data*)vert);
+      wpt_tmp->fs.FsChainAdd(vert);
       route_add_wpt(rte_head, wpt_tmp);
     }
   }
@@ -859,19 +817,14 @@ static void
 Write_One_AN1_Line(const route_head* rte)
 {
   an1_line_record* rec;
-  int local;
 
-  format_specific_data* fs = fs_chain_find(rte->fs, FS_AN1L);
+  const auto* source_rec = reinterpret_cast<an1_line_record*>(rte->fs.FsChainFind(kFsAn1L));
 
-  if (fs) {
-    rec = (an1_line_record*)(void*)fs;
-    local = 0;
+  if (source_rec != nullptr) {
+    rec = source_rec->clone();
     switch (output_type_num) {
     case 1:
       if (rec->type != 14) {
-        rec = Alloc_AN1_Line();
-        memcpy(rec, fs, sizeof(an1_line_record));
-        local = 1;
         rec->roadtype = 0x11100541;
         rec->unk2 = 655360;
         rec->type = 14;
@@ -881,27 +834,20 @@ Write_One_AN1_Line(const route_head* rte)
       break;
     case 2:
       if (rec->type != 15) {
-        rec = Alloc_AN1_Line();
-        memcpy(rec, fs, sizeof(an1_line_record));
-        local = 1;
         rec->type = 15;
       } // end if
       break;
     case 4:
       if (rec->type != 16) {
-        rec = Alloc_AN1_Line();
-        memcpy(rec, fs, sizeof(an1_line_record));
-        local = 1;
         rec->type = 16;
       } // end if
       break;
     }
   } else {
-    rec = Alloc_AN1_Line();
-    local = 1;
+    rec = new an1_line_record;
     rec->name = nullptr;
     switch (output_type_num) {
-      /*  drawing road trail waypoint track  */
+    /*  drawing road trail waypoint track  */
     case 1: /* road */
       rec->roadtype = 0x11100541;
       rec->unk2 = 655360;
@@ -946,34 +892,27 @@ Write_One_AN1_Line(const route_head* rte)
   rec->serial = serial++;
   rec->pointcount = rte->rte_waypt_ct;
   Write_AN1_Line(outfile, rec);
-  if (local) {
-    Destroy_AN1_Line(rec);
-  }
+  delete rec;
 }
 
 static void
 Write_One_AN1_Vertex(const Waypoint* wpt)
 {
   an1_vertex_record* rec;
-  int local;
 
-  format_specific_data* fs = fs_chain_find(wpt->fs, FS_AN1V);
+  const auto* source_rec = reinterpret_cast<an1_vertex_record*>(wpt->fs.FsChainFind(kFsAn1V));
 
-  if (fs) {
-    rec = (an1_vertex_record*)(void*)fs;
-    local = 0;
+  if (source_rec != nullptr) {
+    rec = source_rec->clone();
   } else {
-    rec = Alloc_AN1_Vertex();
-    local = 1;
+    rec = new an1_vertex_record;
     rec->magic = 1;
   }
   rec->lat = EncodeOrd(wpt->latitude);
   rec->lon = EncodeOrd(-wpt->longitude);
 
   Write_AN1_Vertex(outfile, rec);
-  if (local) {
-    Destroy_AN1_Vertex(rec);
-  }
+  delete rec;
 }
 
 static void Write_AN1_Lines(gbfile* f)
index bf78756b396e2fd4a370752b03514ce77896fbbe..df9bca6edfe3a40aa587b91df352268164d20d2c 100644 (file)
--- a/an1sym.h
+++ b/an1sym.h
@@ -710,20 +710,23 @@ static struct defguid {
 
 static int FindIconByName(const char* name, guid_t* guid)
 {
-  for (unsigned int i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); i++) {
+  for (unsigned int i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); ++i) {
     if (!case_ignore_strcmp(name, default_guids[i].name)) {
-      memcpy(guid, &(default_guids[i].guid), sizeof(guid_t));
+      *guid = default_guids[i].guid;
       return 1;
     }
   }
   return 0;
 }
 
-static int FindIconByGuid(guid_t* guid, char** name)
+static int FindIconByGuid(const guid_t* guid, const char** name)
 {
-  for (unsigned int i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); i++) {
-    if (!memcmp(guid, &default_guids[i].guid, sizeof(guid_t))) {
-      *name = const_cast<char*>(default_guids[i].name);
+  for (unsigned int i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); ++i) {
+    /* don't compare any structure padding */
+    if ((guid->l == default_guids[i].guid.l) &&
+        memcmp(guid->s, default_guids[i].guid.s, sizeof(guid->s)) &&
+        memcmp(guid->c, default_guids[i].guid.c, sizeof(guid->c))) {
+      *name = default_guids[i].name;
       return 1;
     }
   }
diff --git a/bend.cc b/bend.cc
index 22b0e639b3ab5c7090dd04d750b8414f836110b8..058827667deb539866b040f3ca0695303de0973a 100644 (file)
--- a/bend.cc
+++ b/bend.cc
@@ -149,7 +149,7 @@ void BendFilter::process_route_orig(const route_head* route_orig)
   auto* route_dest = new route_head;
   route_dest->rte_name = route_orig->rte_name;
   route_dest->rte_desc = route_orig->rte_desc;
-  route_dest->fs = fs_chain_copy(route_orig->fs);
+  route_dest->fs = route_orig->fs.FsChainCopy();
   route_dest->rte_num = route_orig->rte_num;
 
   route_add_head(route_dest);
diff --git a/defs.h b/defs.h
index 6cd0bd00fb0a4e8b8f8da4d3bfa09dab9a35bec7..f5dc7ffdc4972ea050fe393c66c0f8504c275306 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -36,8 +36,6 @@
 #include "zlib.h"               // doesn't really belong here, but is missing elsewhere.
 #endif
 
-#include <QtCore/QByteArray>    // for QByteArray
-#include <QtCore/QChar>         // for QChar
 #include <QtCore/QList>         // for QList, QList<>::const_reverse_iterator, QList<>::reverse_iterator
 #include <QtCore/QString>       // for QString
 #include <QtCore/QStringRef>    // for QStringRef
@@ -46,7 +44,7 @@
 #include <QtCore/Qt>            // for CaseInsensitive
 #include <QtCore/QtGlobal>      // for foreach
 
-#include "cet.h"                // for cet_cs_vec_t
+#include "formspec.h"           // for FormatSpecificData
 #include "inifile.h"            // for inifile_t
 #include "gbfile.h"             // doesn't really belong here, but is missing elsewhere.
 #include "session.h"            // for session_t
@@ -306,17 +304,6 @@ public:
   QString personal_note;
 };
 
-using fs_destroy = void (*)(void*);
-using fs_copy = void (*)(void**, void*);
-
-struct format_specific_data {
-  long type{0};
-  format_specific_data* next{nullptr};
-
-  fs_destroy destroy{nullptr};
-  fs_copy copy{nullptr};
-};
-
 class gb_color
 {
 public:
@@ -324,20 +311,6 @@ public:
   unsigned char opacity{255};  // 0 == transparent.  255 == opaque.
 };
 
-
-format_specific_data* fs_chain_copy(format_specific_data* source);
-void fs_chain_destroy(format_specific_data* chain);
-format_specific_data* fs_chain_find(format_specific_data* chain, long type);
-void fs_chain_add(format_specific_data** chain, format_specific_data* data);
-
-#define FS_GPX 0x67707800L
-#define FS_AN1W 0x616e3177L
-#define FS_AN1L 0x616e316cL
-#define FS_AN1V 0x616e3176L
-#define FS_OZI 0x6f7a6900L
-#define FS_GMSD 0x474d5344L    /* GMSD = Garmin specific data */
-#define FS_LOWRANCEUSR4 0x615f234cL
-
 /*
  * Structures and functions for multiple URLs per waypoint.
  */
@@ -548,7 +521,7 @@ public:
   float temperature; /* Degrees celsius */
   float odometer_distance; /* Meters? */
   geocache_data* gc_data;
-  format_specific_data* fs;
+  FormatSpecificDataList fs;
   const session_t* session;    /* pointer to a session struct */
   void* extra_data;    /* Extra data added by, say, a filter. */
 
@@ -717,7 +690,7 @@ public:
   UrlList rte_urls;
   int rte_num;
   int rte_waypt_ct;            /* # waypoints in waypoint list */
-  format_specific_data* fs;
+  FormatSpecificDataList fs;
   gb_color line_color;         /* Optional line color for rendering */
   int line_width;         /* in pixels (sigh).  < 0 is unknown. */
   const session_t* session;    /* pointer to a session struct */
index e0b42272c016ab024bb643304d8b5ee9dec497a4..27d1f175e88bb38584a3560db8ba625db0246250 100644 (file)
@@ -69,7 +69,7 @@ gmsd_init(Waypoint* wpt)
   garmin_fs_t* gmsd = garmin_fs_t::find(wpt);
   if (gmsd == nullptr) {
     gmsd = garmin_fs_alloc(-1);
-    fs_chain_add(&wpt->fs, (format_specific_data*) gmsd);
+    wpt->fs.FsChainAdd(gmsd);
   }
   return gmsd;
 }
index 7fd303fe945aa831d92ae954a719dba3c76adb23..446241a6716e1afc7dcfb5a4291840e339c9dbe1 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Functions to manage the format_specific_data chain
+    Functions to manage the FormatSpecificData chain
 
     Copyright (C) 2005 Ron Parker and Robert Lipe.
 
 
  */
 
+#include <QtCore/QList>  // for QList
+
 #include "defs.h"
+#include "formspec.h"    // for FormatSpecificData, FsChainAdd, FsChainCopy, FsChainDestroy, FsChainFind
 
-format_specific_data* fs_chain_copy(format_specific_data* source)
+FormatSpecificDataList FormatSpecificDataList::FsChainCopy() const
 {
-  format_specific_data* result = nullptr;
-
-  format_specific_data** copy = &result;
-  while (source) {
-    source->copy((void**)copy, (void*)source);
-    /* prevent segfaults from badly-behaved copy functions */
-    (*copy)->next = nullptr;
-    copy = &((*copy)->next);
-    source = source->next;
+  FormatSpecificDataList dest;
+  for (const auto* item : *this) {
+    dest.append(item->clone());
   }
-  return result;
+  return dest;
 }
 
-void fs_chain_destroy(format_specific_data* chain)
+void FormatSpecificDataList::FsChainDestroy()
 {
-  format_specific_data* cur = chain;
-  while (cur) {
-    format_specific_data* next = cur->next;
-    cur->destroy(cur);
-    cur = next;
+  while (!isEmpty()) {
+    delete takeFirst();
   }
 }
 
-format_specific_data* fs_chain_find(format_specific_data* chain, long type)
+FormatSpecificData* FormatSpecificDataList::FsChainFind(FsType type) const
 {
-  format_specific_data* cur = chain;
-  while (cur) {
-    if (cur->type == type) {
-      return cur;
+  for (auto* item : *this) {
+    if (item->fs_type == type) {
+      return item;
     }
-    cur = cur->next;
   }
   return nullptr;
 }
 
-void fs_chain_add(format_specific_data** chain, format_specific_data* data)
+void FormatSpecificDataList::FsChainAdd(FormatSpecificData* data)
 {
-  data->next = *chain;
-  *chain = data;
+  if (data != nullptr) {
+    append(data);
+  }
 }
-
diff --git a/formspec.h b/formspec.h
new file mode 100644 (file)
index 0000000..075c54a
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+    Functions to manage the FormatSpecificData chain
+
+    Copyright (C) 2005 Ron Parker and Robert Lipe.
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+ */
+#ifndef FORMSPEC_H_INCLUDED_
+#define FORMSPEC_H_INCLUDED_
+
+#include <QtCore/QList>  // for QList
+
+enum FsType {
+  kFsUnknown = 0L,
+  kFsGpx = 0x67707800L,
+  kFsAn1W = 0x616e3177L,
+  kFsAn1L = 0x616e316cL,
+  kFsAn1V = 0x616e3176L,
+  kFsOzi = 0x6f7a6900L,
+  kFsGmsd = 0x474d5344L,       /* GMSD = Garmin specific data */
+  kFsLowranceusr4 = 0x615f234cL
+};
+
+struct FormatSpecificData {
+  FormatSpecificData() = default;
+  explicit FormatSpecificData(FsType type) : fs_type(type) {}
+  FormatSpecificData(const FormatSpecificData&) = default;
+  FormatSpecificData& operator=(const FormatSpecificData&) = default;
+  FormatSpecificData(FormatSpecificData&&) = delete;
+  FormatSpecificData& operator=(FormatSpecificData&&) = delete;
+  virtual ~FormatSpecificData() = default;
+
+  virtual FormatSpecificData* clone() const = 0;
+
+  FsType fs_type{kFsUnknown};
+};
+
+class FormatSpecificDataList : private QList<FormatSpecificData*>
+{
+public:
+  FormatSpecificDataList FsChainCopy() const;
+  void FsChainDestroy();
+  FormatSpecificData* FsChainFind(FsType type) const;
+  void FsChainAdd(FormatSpecificData* data);
+};
+
+#endif // FORMSPEC_H_INCLUDED_
index ed2fa0552c0abf9ab674b5af619eb6088197bacd..a0fc62cb1cc2a23bd735a915cf8157e13c179bb6 100644 (file)
@@ -75,7 +75,7 @@ static void
 parse_line(char* buff, int index, const char* delimiter, Waypoint* wpt)
 {
   char* cin;
-  garmin_fs_p gmsd = garmin_fs_t::find(wpt);
+  garmin_fs_t* gmsd = garmin_fs_t::find(wpt);
 
   while ((cin = csv_lineparse(buff, delimiter, "", index++))) {
 
@@ -273,8 +273,8 @@ parse_waypt(char* buff)
   struct tm tm;
 
   auto* wpt = new Waypoint;
-  garmin_fs_p gmsd = garmin_fs_alloc(-1);
-  fs_chain_add(&wpt->fs, (format_specific_data*) gmsd);
+  garmin_fs_t* gmsd = garmin_fs_alloc(-1);
+  wpt->fs.FsChainAdd(gmsd);
 
   if (gardown) {
     cin = buff + 6;
@@ -344,8 +344,8 @@ static Waypoint*
 parse_trkpt(char* buff)
 {
   auto* wpt = new Waypoint;
-  garmin_fs_p gmsd = garmin_fs_alloc(-1);
-  fs_chain_add(&wpt->fs, (format_specific_data*) gmsd);
+  garmin_fs_t* gmsd = garmin_fs_alloc(-1);
+  wpt->fs.FsChainAdd(gmsd);
 
   parse_line(buff, TRKPT__OFS, ";", wpt);
 
index 973255f0813b71f8d192eac3d6fceda4f850512a..232d7f339aa227cfe0d91f0542d1ee49f4dce530 100644 (file)
 
  */
 
+#include <cassert>                   // for assert
+#include <cstdio>                    // for snprintf, sscanf
+#include <cstdlib>                   // for atof
+#include <cstring>                   // for strncpy
+
+#include <QtCore/QByteArray>         // for QByteArray
+#include <QtCore/QStaticStringData>  // for QStaticStringData
+#include <QtCore/QString>            // for QString, QStringLiteral
+#include <QtCore/QXmlStreamWriter>   // for QXmlStreamWriter
+#include <QtCore/Qt>                 // for CaseInsensitive
+
 #include "defs.h"
-#include "cet_util.h"
 #include "garmin_fs.h"
-#include "garmin_tables.h"
-#include "inifile.h"
+#include "garmin_tables.h"           // for gt_switch_display_mode_value, gt_display_mode_symbol, gt_display_mode_symbol_and_comment, gt_display_mode_symbol_and_name
+#include "inifile.h"                 // for inifile_readstr
+#include "jeeps/gps.h"               // for gps_waypt_type
 
-#include <QtCore/QString>
-#include <QtCore/QXmlStreamWriter>
-#include <cassert>
-#include <cstdio>
-#include <cstdlib>
 
 #define MYNAME "garmin_fs"
 
@@ -38,20 +44,26 @@ garmin_fs_t*
 garmin_fs_alloc(const int protocol)
 {
   auto* result = new garmin_fs_t;
-  result->fs.type = FS_GMSD;
-  result->fs.copy = (fs_copy) garmin_fs_copy;
-  result->fs.destroy = garmin_fs_destroy;
-  result->fs.next = nullptr;
 
   result->protocol = protocol;
 
   return result;
 }
 
-void
-garmin_fs_destroy(void* fs)
+garmin_fs_t* garmin_fs_t::clone() const
 {
-  delete (garmin_fs_t*) fs;
+  auto* copy = new garmin_fs_t(*this);
+
+  /* do not deep copy interlinks, only increment the reference counter */
+  if (ilinks != nullptr) {
+    ilinks->ref_count++;
+  }
+
+#ifdef GMSD_EXPERIMENTAL
+  memcopy(subclass, other.subclass, sizeof(subclass));
+#endif
+
+  return copy;
 }
 
 garmin_fs_t::~garmin_fs_t()
@@ -69,47 +81,6 @@ garmin_fs_t::~garmin_fs_t()
   }
 }
 
-void garmin_fs_copy(garmin_fs_t** dest, garmin_fs_t* src)
-{
-  if (src == nullptr) {
-    *dest = nullptr;
-    return;
-  }
-  *dest = new garmin_fs_t(*src);
-}
-
-garmin_fs_t::garmin_fs_t(const garmin_fs_t& other) :
-  fs(other.fs),
-  flags(other.flags),
-  protocol(other.protocol),
-  icon(other.icon),
-  wpt_class(other.wpt_class),
-  display(other.display),
-  category(other.category),
-  city(other.city),
-  facility(other.facility),
-  state(other.state),
-  cc(other.cc),
-  cross_road(other.cross_road),
-  addr(other.addr),
-  country(other.country),
-  phone_nr(other.phone_nr),
-  phone_nr2(other.phone_nr2),
-  fax_nr(other.fax_nr),
-  postal_code(other.postal_code),
-  email(other.email),
-  ilinks(other.ilinks)
-{
-  /* do not deep copy interlinks, only increment the reference counter */
-  if (ilinks != nullptr) {
-    ilinks->ref_count++;
-  }
-
-#ifdef GMSD_EXPERIMENTAL
-  memcopy(subclass, other.subclass, sizeof(subclass));
-#endif
-}
-
 /* GPX - out */
 
 void
@@ -224,7 +195,7 @@ garmin_fs_xml_convert(const int base_tag, int tag, const QString& qstr, Waypoint
   garmin_fs_t* gmsd = garmin_fs_t::find(waypt);
   if (gmsd == nullptr) {
     gmsd = garmin_fs_alloc(-1);
-    fs_chain_add(&waypt->fs, (format_specific_data*) gmsd);
+    waypt->fs.FsChainAdd(gmsd);
   }
 
   tag -= base_tag;
@@ -350,7 +321,7 @@ garmin_fs_merge_category(const char* category_name, Waypoint* waypt)
 
   if (gmsd == nullptr) {
     gmsd = garmin_fs_alloc(-1);
-    fs_chain_add(&waypt->fs, (format_specific_data*) gmsd);
+    waypt->fs.FsChainAdd(gmsd);
   }
   garmin_fs_t::set_category(gmsd, cat);
   return 1;
@@ -360,7 +331,7 @@ void
 garmin_fs_garmin_after_read(const GPS_PWay way, Waypoint* wpt, const int protoid)
 {
   garmin_fs_t* gmsd = garmin_fs_alloc(protoid);
-  fs_chain_add(&wpt->fs, (format_specific_data*) gmsd);
+  wpt->fs.FsChainAdd(gmsd);
 
   /* nothing happens until gmsd is allocated some lines above */
 
index 0ee77300c845c2c8ff84072d44c313558eda093b..cd68fc1847f2a4bd7b98f48ba035dcf219af6204 100644 (file)
 #ifndef GARMIN_FS_H
 #define GARMIN_FS_H
 
+#include <cstddef>                  // for size_t
+#include <cstdint>                  // for int32_t, int16_t, uint16_t
+
+#include <QtCore/QString>           // for QString
+#include <QtCore/QXmlStreamWriter>  // for QXmlStreamWriter
+
 #include "defs.h"
+#include "formspec.h"               // for FsChainFind, kFsGmsd, FormatSpecificData
 #include "jeeps/gps.h"
 
+
 /* this order is used by most devices */
 /* enum garmin_display_t {
        garmin_display_symbol_and_name = 0,
@@ -86,9 +94,8 @@ public:
 #endif
 };
 
-class garmin_fs_t {
+class garmin_fs_t : public FormatSpecificData {
 public:
-  format_specific_data fs;
   garmin_fs_flags_t flags;
 
   int protocol{0};             /* ... used by device (-1 is MapSource) */
@@ -115,15 +122,18 @@ public:
 #endif
 
 public:
-  garmin_fs_t() = default;
-  ~garmin_fs_t();
-  garmin_fs_t(const garmin_fs_t& other);
+  garmin_fs_t() : FormatSpecificData(kFsGmsd) {}
+private:
+  garmin_fs_t(const garmin_fs_t& other) = default;
+public:
   garmin_fs_t& operator=(const garmin_fs_t& rhs) = delete; /* not implemented */
   garmin_fs_t(garmin_fs_t&&) = delete; /* not implemented */
   garmin_fs_t& operator=(garmin_fs_t&&) = delete; /* not implemented */
+  ~garmin_fs_t() override;
 
+  garmin_fs_t* clone() const override;
   static garmin_fs_t* find(const Waypoint* wpt) {
-    return (garmin_fs_t*) fs_chain_find(wpt->fs, FS_GMSD);
+    return reinterpret_cast<garmin_fs_t*>(wpt->fs.FsChainFind(kFsGmsd));
   }
 
 #define GEN_GMSD_METHODS(field) \
@@ -201,17 +211,14 @@ public:
 
 #undef GEN_GMSD_STR_METHODS
 };
-using garmin_fs_p = garmin_fs_t*;
 
 garmin_fs_t* garmin_fs_alloc(int protocol);
 void garmin_fs_destroy(void* fs);
-void garmin_fs_copy(garmin_fs_t** dest, garmin_fs_t* src);
-void garmin_fs_convert(void* fs);
+void garmin_fs_copy(void** dest, const void* src);
 char* garmin_fs_xstrdup(const char* src, size_t size);
 
 /* for GPX */
 void garmin_fs_xml_convert(int base_tag, int tag, const QString& qstr, Waypoint* waypt);
-class QXmlStreamWriter;
 void garmin_fs_xml_fprint(const Waypoint* waypt, QXmlStreamWriter*);
 
 /* common garmin_fs utilities */
index d68db9e46fad3cafb03decd5a81cbd02f5d2678b..952962e0cb1317399311424348306ee40c5a6670 100644 (file)
@@ -249,7 +249,7 @@ gpi_gmsd_init(Waypoint* wpt)
   }
   if (gmsd == nullptr) {
     gmsd = garmin_fs_alloc(-1);
-    fs_chain_add(&wpt->fs, (format_specific_data*) gmsd);
+    wpt->fs.FsChainAdd(gmsd);
   }
   return gmsd;
 }
index 9abbeda585e99bc575105e4fe61654cb30fa5d30..03b83a643416afed879d42fd49aa260363420356 100644 (file)
@@ -41,7 +41,7 @@
 #include <QtCore/QtGlobal>         // for qPrintable
 
 #include "csv_util.h"              // for csv_lineparse
-#include "garmin_fs.h"             // for garmin_fs_t, garmin_fs_alloc, garmin_fs_convert_category, garmin_fs_p, GMSD_SECTION_CATEGORIES
+#include "garmin_fs.h"             // for garmin_fs_t, garmin_fs_alloc, garmin_fs_convert_category, GMSD_SECTION_CATEGORIES
 #include "garmin_tables.h"         // for gt_display_modes_e, gt_find_desc_from_icon_number, gt_find_icon_number_from_desc, gt_get_mps_grid_longname, gt_lookup_datum_index, gt_lookup_grid_type, GDB, gt_get_icao_cc, gt_get_icao_country, gt_get_mps_datum_name, gt_waypt_class_names, GT_DISPLAY_MODE...
 #include "inifile.h"               // for inifile_readstr
 #include "jeeps/gpsmath.h"         // for GPS_Math_Known_Datum_To_UTM_EN, GPS_Math_WGS84_To_Known_Datum_M, GPS_Math_WGS84_To_Swiss_EN, GPS_Math_WGS84_To_UKOSMap_M
@@ -215,7 +215,7 @@ convert_datum(const Waypoint* wpt, double* dest_lat, double* dest_lon)
 static void
 enum_waypt_cb(const Waypoint* wpt)
 {
-  garmin_fs_p gmsd = garmin_fs_t::find(wpt);
+  garmin_fs_t* gmsd = garmin_fs_t::find(wpt);
   int wpt_class = garmin_fs_t::get_wpt_class(gmsd, 0);
   if (wpt_class < 0x80) {
     if (gtxt_flags.enum_waypoints) {           /* enumerate only */
@@ -535,7 +535,7 @@ write_waypt(const Waypoint* wpt)
 {
   const char* wpt_type;
 
-  garmin_fs_p gmsd = garmin_fs_t::find(wpt);
+  garmin_fs_t* gmsd = garmin_fs_t::find(wpt);
 
   int i = garmin_fs_t::get_display(gmsd, 0);
   if (i > GT_DISPLAY_MODE_MAX) {
@@ -1090,8 +1090,8 @@ parse_waypoint()
   bind_fields(waypt_header);
 
   auto* wpt = new Waypoint;
-  garmin_fs_p gmsd = garmin_fs_alloc(-1);
-  fs_chain_add(&wpt->fs, (format_specific_data*) gmsd);
+  garmin_fs_t* gmsd = garmin_fs_alloc(-1);
+  wpt->fs.FsChainAdd(gmsd);
 
   while ((str = csv_lineparse(nullptr, "\t", "", column++))) {
     int i;
diff --git a/gdb.cc b/gdb.cc
index 1621a8bf86a9efb76eef653499050dc7ffaa19fb..d32664cabc49a6bae18d97931ebd7e81b9e94c6d 100644 (file)
--- a/gdb.cc
+++ b/gdb.cc
@@ -437,7 +437,7 @@ read_waypoint(gt_waypt_classes_e* waypt_class_out)
   res = new Waypoint;
 
   gmsd = garmin_fs_alloc(-1);
-  fs_chain_add(&res->fs, (format_specific_data*) gmsd);
+  res->fs.FsChainAdd(gmsd);
   res->shortname = fread_cstr();
   wpt_class = (gt_waypt_classes_e) FREAD_i32;
   garmin_fs_t::set_wpt_class(gmsd, wpt_class);
@@ -818,7 +818,7 @@ read_route()
       garmin_fs_t* gmsd = garmin_fs_t::find(wpt);
       if (gmsd == nullptr) {
         gmsd = garmin_fs_alloc(-1);
-        fs_chain_add(&wpt->fs, (format_specific_data*) gmsd);
+        wpt->fs.FsChainAdd(gmsd);
       }
       garmin_fs_t::set_wpt_class(gmsd, wpt_class);
       gmsd->ilinks = il_root;
diff --git a/gpx.cc b/gpx.cc
index e55e7e0bdc10f04d2dd9ea6016d3975a66f99dd7..c2b5033147c1029b9541f939851d12096fd506a9 100644 (file)
--- a/gpx.cc
+++ b/gpx.cc
@@ -34,7 +34,6 @@
 #include <QtCore/QStringList>                      // for QStringList
 #include <QtCore/QStringRef>                       // for QStringRef
 #include <QtCore/QTime>                            // for QTime
-#include <QtCore/QVector>                          // for QVector
 #include <QtCore/QVersionNumber>                   // for QVersionNumber
 #include <QtCore/QXmlStreamAttribute>              // for QXmlStreamAttribute
 #include <QtCore/QXmlStreamAttributes>             // for QXmlStreamAttributes
@@ -266,7 +265,7 @@ GpxFormat::start_something_else(const QString& el, const QXmlStreamAttributes& a
       new_tag->parent = cur_tag;
     }
   } else {
-    auto* fs_gpx = (fs_xml*)fs_chain_find(*fs_ptr, FS_GPX);
+    const auto* fs_gpx = reinterpret_cast<fs_xml*>(fs_ptr->FsChainFind(kFsGpx));
 
     if (fs_gpx && fs_gpx->tag) {
       cur_tag = fs_gpx->tag;
@@ -276,9 +275,9 @@ GpxFormat::start_something_else(const QString& el, const QXmlStreamAttributes& a
       cur_tag->sibling = new_tag;
       new_tag->parent = nullptr;
     } else {
-      fs_gpx = fs_xml_alloc(FS_GPX);
-      fs_gpx->tag = new_tag;
-      fs_chain_add(fs_ptr, (format_specific_data*)fs_gpx);
+      fs_xml* new_fs_gpx = fs_xml_alloc(kFsGpx);
+      new_fs_gpx->tag = new_tag;
+      fs_ptr->FsChainAdd(new_fs_gpx);
       new_tag->parent = nullptr;
     }
   }
@@ -1407,7 +1406,7 @@ GpxFormat::gpx_waypt_pr(const Waypoint* waypointp)
   gpx_write_common_acc(waypointp);
 
   if (!(opt_humminbirdext || opt_garminext)) {
-    auto* fs_gpx = (fs_xml*)fs_chain_find(waypointp->fs, FS_GPX);
+    const auto* fs_gpx = reinterpret_cast<fs_xml*>(waypointp->fs.FsChainFind(kFsGpx));
     auto* gmsd = garmin_fs_t::find(waypointp); /* gARmIN sPECIAL dATA */
     if (fs_gpx) {
       if (! gmsd) {
@@ -1440,7 +1439,7 @@ GpxFormat::gpx_track_hdr(const route_head* rte)
 
   if (gpx_write_version > gpx_1_0) {
     if (!(opt_humminbirdext || opt_garminext)) {
-      auto* fs_gpx = (fs_xml*)fs_chain_find(rte->fs, FS_GPX);
+      const auto* fs_gpx = reinterpret_cast<fs_xml*>(rte->fs.FsChainFind(kFsGpx));
       if (fs_gpx) {
         fprint_xml_chain(fs_gpx->tag, nullptr);
       }
@@ -1487,7 +1486,7 @@ GpxFormat::gpx_track_disp(const Waypoint* waypointp)
   gpx_write_common_acc(waypointp);
 
   if (!(opt_humminbirdext || opt_garminext)) {
-    auto* fs_gpx = (fs_xml*)fs_chain_find(waypointp->fs, FS_GPX);
+    const auto* fs_gpx = reinterpret_cast<fs_xml*>(waypointp->fs.FsChainFind(kFsGpx));
     if (fs_gpx) {
       fprint_xml_chain(fs_gpx->tag, waypointp);
     }
@@ -1538,7 +1537,7 @@ GpxFormat::gpx_route_hdr(const route_head* rte)
 
   if (gpx_write_version > gpx_1_0) {
     if (!(opt_humminbirdext || opt_garminext)) {
-      auto* fs_gpx = (fs_xml*)fs_chain_find(rte->fs, FS_GPX);
+      const auto* fs_gpx = reinterpret_cast<fs_xml*>(rte->fs.FsChainFind(kFsGpx));
       if (fs_gpx) {
         fprint_xml_chain(fs_gpx->tag, nullptr);
       }
@@ -1575,7 +1574,7 @@ GpxFormat::gpx_route_disp(const Waypoint* waypointp)
   gpx_write_common_acc(waypointp);
 
   if (!(opt_humminbirdext || opt_garminext)) {
-    auto* fs_gpx = (fs_xml*)fs_chain_find(waypointp->fs, FS_GPX);
+    const auto* fs_gpx = reinterpret_cast<fs_xml*>(waypointp->fs.FsChainFind(kFsGpx));
     if (fs_gpx) {
       fprint_xml_chain(fs_gpx->tag, waypointp);
     }
diff --git a/gpx.h b/gpx.h
index 2ef8d6aaec7a41916cc22b469ad29fbedc603441..ab503658678d3c82e57a55410d5df77f592d7243 100644 (file)
--- a/gpx.h
+++ b/gpx.h
@@ -22,6 +22,7 @@
 #define GPX_H_INCLUDED_
 
 #include <QtCore/QHash>                 // for QHash
+#include <QtCore/QList>                 // for QList
 #include <QtCore/QString>               // for QString
 #include <QtCore/QStringList>           // for QStringList
 #include <QtCore/QVector>               // for QVector
@@ -31,6 +32,7 @@
 
 #include "defs.h"
 #include "format.h"                     // for Format
+#include "formspec.h"                   // for FormatSpecificData
 #include "src/core/file.h"              // for File
 #include "src/core/xmlstreamwriter.h"   // for XmlStreamWriter
 #include "src/core/xmltag.h"            // for xml_tag
@@ -261,7 +263,7 @@ private:
   bounds all_bounds;
   int next_trkpt_is_new_seg;
 
-  format_specific_data** fs_ptr;
+  FormatSpecificDataList* fs_ptr;
 
   /*
    * The file-level information.
diff --git a/html.cc b/html.cc
index 5f2d56f64566cf8de7d2fcc6f0c630457f1862f4..20c33cb9d72d2fb1fd6155acad8f00fe787ffa72 100644 (file)
--- a/html.cc
+++ b/html.cc
@@ -27,6 +27,7 @@
 #include <QtCore/Qt>               // for CaseInsensitive
 
 #include "defs.h"
+#include "formspec.h"              // for FsChainFind, kFsGpx
 #include "gbfile.h"                // for gbfprintf, gbfclose, gbfopen, gbfputs, gbfile
 #include "jeeps/gpsmath.h"         // for GPS_Math_WGS84_To_UTM_EN
 #include "src/core/datetime.h"     // for DateTime
@@ -156,73 +157,71 @@ html_disp(const Waypoint* wpt)
     gbfprintf(file_out, "<p class=\"gpsbabelnotes\">%s</p>\n", CSTR(wpt->notes));
   }
 
-  fs_xml* fs_gpx = nullptr;
   if (includelogs) {
-    fs_gpx = (fs_xml*)fs_chain_find(wpt->fs, FS_GPX);
-  }
-
-  if (fs_gpx && fs_gpx->tag) {
-    xml_tag* root = fs_gpx->tag;
-    xml_tag* curlog = xml_findfirst(root, "groundspeak:log");
-    while (curlog) {
-      time_t logtime = 0;
-      gbfprintf(file_out, "<p class=\"gpsbabellog\">\n");
+    const auto* fs_gpx = reinterpret_cast<fs_xml*>(wpt->fs.FsChainFind(kFsGpx));
+    if (fs_gpx && fs_gpx->tag) {
+      xml_tag* root = fs_gpx->tag;
+      xml_tag* curlog = xml_findfirst(root, "groundspeak:log");
+      while (curlog) {
+        time_t logtime = 0;
+        gbfprintf(file_out, "<p class=\"gpsbabellog\">\n");
+
+        xml_tag* logpart = xml_findfirst(curlog, "groundspeak:type");
+        if (logpart) {
+          gbfprintf(file_out, "<span class=\"gpsbabellogtype\">%s</span> by ", CSTR(logpart->cdata));
+        }
 
-      xml_tag* logpart = xml_findfirst(curlog, "groundspeak:type");
-      if (logpart) {
-        gbfprintf(file_out, "<span class=\"gpsbabellogtype\">%s</span> by ", CSTR(logpart->cdata));
-      }
+        logpart = xml_findfirst(curlog, "groundspeak:finder");
+        if (logpart) {
+          char* f = html_entitize(CSTR(logpart->cdata));
+          gbfprintf(file_out, "<span class=\"gpsbabellogfinder\">%s</span> on ", f);
+          xfree(f);
+        }
 
-      logpart = xml_findfirst(curlog, "groundspeak:finder");
-      if (logpart) {
-        char* f = html_entitize(CSTR(logpart->cdata));
-        gbfprintf(file_out, "<span class=\"gpsbabellogfinder\">%s</span> on ", f);
-        xfree(f);
-      }
+        logpart = xml_findfirst(curlog, "groundspeak:date");
+        if (logpart) {
+          logtime = xml_parse_time(logpart->cdata).toTime_t();
+          struct tm* logtm = localtime(&logtime);
+          if (logtm) {
+            gbfprintf(file_out,
+                      "<span class=\"gpsbabellogdate\">%04d-%02d-%02d</span><br>\n",
+                      logtm->tm_year+1900,
+                      logtm->tm_mon+1,
+                      logtm->tm_mday);
+          }
+        }
 
-      logpart = xml_findfirst(curlog, "groundspeak:date");
-      if (logpart) {
-        logtime = xml_parse_time(logpart->cdata).toTime_t();
-        struct tm* logtm = localtime(&logtime);
-        if (logtm) {
+        logpart = xml_findfirst(curlog, "groundspeak:log_wpt");
+        if (logpart) {
+          double lat = xml_attribute(logpart->attributes, "lat").toDouble();
+          double lon = xml_attribute(logpart->attributes, "lon").toDouble();
+          char* coordstr = pretty_deg_format(lat, lon, degformat[2], " ", 1);
           gbfprintf(file_out,
-                    "<span class=\"gpsbabellogdate\">%04d-%02d-%02d</span><br>\n",
-                    logtm->tm_year+1900,
-                    logtm->tm_mon+1,
-                    logtm->tm_mday);
+                    "<span class=\"gpsbabellogcoords\">%s</span><br>\n",
+                    coordstr);
+          xfree(coordstr);
         }
-      }
-
-      logpart = xml_findfirst(curlog, "groundspeak:log_wpt");
-      if (logpart) {
-        double lat = xml_attribute(logpart->attributes, "lat").toDouble();
-        double lon = xml_attribute(logpart->attributes, "lon").toDouble();
-        char* coordstr = pretty_deg_format(lat, lon, degformat[2], " ", 1);
-        gbfprintf(file_out,
-                  "<span class=\"gpsbabellogcoords\">%s</span><br>\n",
-                  coordstr);
-        xfree(coordstr);
-      }
-
-      logpart = xml_findfirst(curlog, "groundspeak:text");
-      if (logpart) {
-        QString encstr = xml_attribute(logpart->attributes, "encoded");
-        bool encoded = !encstr.startsWith('F', Qt::CaseInsensitive);
 
-        QString s;
-        if (html_encrypt && encoded) {
-          s = rot13(logpart->cdata);
-        } else {
-          s = logpart->cdata;
+        logpart = xml_findfirst(curlog, "groundspeak:text");
+        if (logpart) {
+          QString encstr = xml_attribute(logpart->attributes, "encoded");
+          bool encoded = !encstr.startsWith('F', Qt::CaseInsensitive);
+
+          QString s;
+          if (html_encrypt && encoded) {
+            s = rot13(logpart->cdata);
+          } else {
+            s = logpart->cdata;
+          }
+
+          char* t = html_entitize(s);
+          gbfputs(t, file_out);
+          xfree(t);
         }
 
-        char* t = html_entitize(s);
-        gbfputs(t, file_out);
-        xfree(t);
+        gbfprintf(file_out, "</p>\n");
+        curlog = xml_findnext(root, curlog, "groundspeak:log");
       }
-
-      gbfprintf(file_out, "</p>\n");
-      curlog = xml_findnext(root, curlog, "groundspeak:log");
     }
   }
   gbfprintf(file_out, "</td></tr></table>\n");
index 9d245182c41c56c00b19ede657254fc1b237565d..bd8e1a348f2ef5af0555b48fba506fe8d28650ab 100644 (file)
@@ -60,7 +60,7 @@ void InterpolateFilter::process()
     rte_new->rte_desc = rte_old->rte_desc;
     rte_new->rte_urls = rte_old->rte_urls;
     rte_new->rte_num = rte_old->rte_num;
-    rte_new->fs = fs_chain_copy(rte_old->fs);
+    rte_new->fs = rte_old->fs.FsChainCopy();
     rte_new->line_color = rte_old->line_color;
     rte_new->line_width = rte_old->line_width;
     rte_new->session = rte_old->session;
diff --git a/kml.cc b/kml.cc
index f218db759e1276ea7b783fedbe639a8a46550644..1302fb3cfec6c08f67c88c095cad7fb20a14fc14 100644 (file)
--- a/kml.cc
+++ b/kml.cc
@@ -47,6 +47,7 @@
 #include <QtCore/QtGlobal>              // for foreach, qint64, qPrintable
 
 #include "defs.h"
+#include "formspec.h"                   // for FsChainFind, kFsGpx
 #include "grtcirc.h"                    // for RAD, gcdist, radtometers
 #include "src/core/datetime.h"          // for DateTime
 #include "src/core/file.h"              // for File
@@ -1433,7 +1434,7 @@ static QString kml_geocache_get_logs(const Waypoint* wpt)
 {
   QString r;
 
-  auto* fs_gpx = (fs_xml*)fs_chain_find(wpt->fs, FS_GPX);
+  const auto* fs_gpx = reinterpret_cast<fs_xml*>(wpt->fs.FsChainFind(kFsGpx));
 
   if (!fs_gpx) {
     return r;
index 414a8af64ad7f86ab26acf797ec730dce7f932a5..09b84a4eb58a8560edf6cdac8aaec2f55b3e6221 100644 (file)
 #include <QtCore/QtGlobal>        // for qPrintable, uint, qAsConst, QAddConst<>::Type
 
 #include "defs.h"
+#include "formspec.h"             // for FsChainFind, FsChainAdd, kFsLowranceusr4, FormatSpecificData
 #include "gbfile.h"               // for gbfgetint32, gbfputint32, gbfputint16, gbfgetc, gbfgetint16, gbfwrite, gbfputc, gbfeof, gbfgetflt, gbfclose, gbfgetdbl, gbfopen_le, gbfputdbl, gbfputs, gbfile, gbfputflt, gbfread, gbfseek
 #include "src/core/datetime.h"    // for DateTime
 #include "src/core/logging.h"     // for Warning
@@ -370,21 +371,27 @@ static QTextCodec*    utf16le_codec{nullptr};
 /* Jan 1, 2000 00:00:00 */
 const time_t base_time_secs = 946706400;
 
-struct lowranceusr4_fsdata {
-  format_specific_data fs;
-  uint uid_unit;
-  uint uid_unit2;
-  int uid_seq_low;
-  int uid_seq_high;
-  uint UUID1;
-  uint UUID2;
-  uint UUID3;
-  uint UUID4;
-  int  flags;
-  int  color;
-  const char *color_desc;
-  int  icon_num;
-  float depth;
+struct lowranceusr4_fsdata : FormatSpecificData {
+  lowranceusr4_fsdata() : FormatSpecificData(kFsLowranceusr4) {}
+
+  lowranceusr4_fsdata* clone() const override
+  {
+    return new lowranceusr4_fsdata(*this);
+  }
+
+  uint uid_unit{0};
+  uint uid_unit2{0};
+  int uid_seq_low{0};
+  int uid_seq_high{0};
+  uint UUID1{0};
+  uint UUID2{0};
+  uint UUID3{0};
+  uint UUID4{0};
+  int  flags{0};
+  int  color{0};
+  const char *color_desc{nullptr};
+  int  icon_num{0};
+  float depth{0.0};
 };
 
 class Lowranceusr4Timestamp {
@@ -396,38 +403,6 @@ class Lowranceusr4Timestamp {
 };
 
 
-/* fsdata manipulation functions */
-static void
-lowranceusr4_free_fsdata(void* fsdata)
-{
-  xfree(fsdata);
-}
-
-static void
-lowranceusr4_copy_fsdata(lowranceusr4_fsdata** dest, lowranceusr4_fsdata* src)
-{
-  *dest = (lowranceusr4_fsdata*)xmalloc(sizeof(*src));
-  ** dest = *src;
-  (*dest)->fs.next = nullptr;
-}
-
-static
-lowranceusr4_fsdata*
-lowranceusr4_alloc_fsdata()
-{
-  auto* fsdata = (lowranceusr4_fsdata*) xcalloc(1, sizeof(lowranceusr4_fsdata));
-  fsdata->fs.type = FS_LOWRANCEUSR4;
-  fsdata->fs.copy = (fs_copy) lowranceusr4_copy_fsdata;
-  fsdata->fs.destroy = lowranceusr4_free_fsdata;
-
-  fsdata->uid_unit = 0;
-  fsdata->uid_seq_low = 0;
-  fsdata->uid_seq_high = 0;
-
-  return fsdata;
-}
-
-
 
 /* below couple of functions mostly borrowed from raymarine.c */
 
@@ -463,11 +438,9 @@ register_waypt(const Waypoint* wpt)
 static const Waypoint*
 lowranceusr4_find_waypt(uint uid_unit, int uid_seq_low, int uid_seq_high)
 {
-  lowranceusr4_fsdata* fs = nullptr;
-
   // Iterate with waypt_disp_all?
   for (const Waypoint* waypointp : qAsConst(*global_waypoint_list)) {
-    fs = (lowranceusr4_fsdata*) fs_chain_find(waypointp->fs, FS_LOWRANCEUSR4);
+    const auto* fs = reinterpret_cast<lowranceusr4_fsdata*>(waypointp->fs.FsChainFind(kFsLowranceusr4));
 
     if (fs && fs->uid_unit == uid_unit &&
         fs->uid_seq_low == uid_seq_low &&
@@ -486,11 +459,9 @@ lowranceusr4_find_waypt(uint uid_unit, int uid_seq_low, int uid_seq_high)
 static const Waypoint*
 lowranceusr4_find_global_waypt(uint id1, uint id2, uint id3, uint id4)
 {
-  lowranceusr4_fsdata* fs = nullptr;
-
   // Iterate with waypt_disp_all?
   for (const Waypoint* waypointp : qAsConst(*global_waypoint_list)) {
-    fs = (lowranceusr4_fsdata*) fs_chain_find(waypointp->fs, FS_LOWRANCEUSR4);
+    const auto* fs = reinterpret_cast<lowranceusr4_fsdata*>(waypointp->fs.FsChainFind(kFsLowranceusr4));
 
     if (fs && fs->UUID1 == id1 &&
         fs->UUID2 == id2 &&
@@ -921,8 +892,8 @@ lowranceusr4_parse_waypt(Waypoint* wpt_tmp)
 {
   int waypoint_version;
 
-  lowranceusr4_fsdata* fsdata = lowranceusr4_alloc_fsdata();
-  fs_chain_add(&(wpt_tmp->fs), (format_specific_data*) fsdata);
+  auto* fsdata = new lowranceusr4_fsdata;
+  wpt_tmp->fs.FsChainAdd(fsdata);
 
   if (reading_version > 4) {
     /* USR 5 and 6 have four additional data values at the start of each Waypoint */
@@ -1171,8 +1142,8 @@ lowranceusr4_parse_route()
   int UUID3 = 0;
   int UUID4 = 0;
 
-  lowranceusr4_fsdata* fsdata = lowranceusr4_alloc_fsdata();
-  fs_chain_add(&(rte_head->fs), (format_specific_data*) fsdata);
+  auto* fsdata = new lowranceusr4_fsdata;
+  rte_head->fs.FsChainAdd(fsdata);
 
   if (reading_version >= 5) {
     /* Routes have Universal IDs */
@@ -1423,8 +1394,8 @@ lowranceusr4_parse_trail(int* trail_num)
   int trail_color;
   int trail_flags;
 
-  lowranceusr4_fsdata* fsdata = lowranceusr4_alloc_fsdata();
-  fs_chain_add(&(trk_head->fs), (format_specific_data*) fsdata);
+  auto* fsdata = new lowranceusr4_fsdata;
+  trk_head->fs.FsChainAdd(fsdata);
 
   /* UID unit number */
   fsdata->uid_unit = gbfgetint32(file_in);
@@ -1784,7 +1755,7 @@ lowranceusr_waypt_disp(const Waypoint* wpt)
 static void
 lowranceusr4_waypt_disp(const Waypoint* wpt)
 {
-  auto* fs = (lowranceusr4_fsdata*) fs_chain_find(wpt->fs, FS_LOWRANCEUSR4);
+  const auto* fs = reinterpret_cast<lowranceusr4_fsdata*>(wpt->fs.FsChainFind(kFsLowranceusr4));
 
   /* UID unit number */
   if (opt_serialnum_i > 0) {
@@ -2030,7 +2001,7 @@ lowranceusr4_route_hdr(const route_head* rte)
            route_uid, qPrintable(rte->rte_name), rte->rte_waypt_ct);
   }
 
-  auto* fs = (lowranceusr4_fsdata*) fs_chain_find(rte->fs, FS_LOWRANCEUSR4);
+  const auto* fs = reinterpret_cast<lowranceusr4_fsdata*>(rte->fs.FsChainFind(kFsLowranceusr4));
 
   /* UID unit number */
   if (opt_serialnum_i > 0) {
@@ -2061,7 +2032,7 @@ lowranceusr4_route_leg_disp(const Waypoint* wpt)
   for (int i = 0; i < waypt_table->size(); i++) {
     const Waypoint* cmp = waypt_table->at(i);
     if (cmp->shortname == wpt->shortname) {
-      auto* fs = (lowranceusr4_fsdata*) fs_chain_find(cmp->fs, FS_LOWRANCEUSR4);
+      const auto* fs = reinterpret_cast<lowranceusr4_fsdata*>(cmp->fs.FsChainFind(kFsLowranceusr4));
 
       if (opt_serialnum_i > 0) {
         gbfputint32(opt_serialnum_i, file_out);  // use option serial number if specified
index 6f2b7f0bd7bd3f22870a68ba2889b1dd8a0c7d18..16d08f52ae8672ac350aa49dbb1c6f6870f9cfaa 100755 (executable)
@@ -214,7 +214,7 @@ sub DoImage {
 \r
 sub print_header {\r
 print <<'END';\r
-/* \r
+/*\r
 \r
 \r
 \r
@@ -257,7 +257,7 @@ print <<'END';
 \r
 /*\r
     Read DeLorme drawing files (.an1) - supplemental (included by an1.c)\r
\r
+\r
     Copyright (C) 2005 Ron Parker and Robert Lipe.\r
 \r
     This program is free software; you can redistribute it and/or modify\r
@@ -277,8 +277,8 @@ print <<'END';
  */\r
 \r
 static struct defguid {\r
-       guid_t guid;\r
-       const char *name;\r
+  guid_t guid;\r
+  const char* name;\r
 } default_guids[] = {\r
 END\r
 }\r
@@ -287,28 +287,29 @@ sub print_footer {
 print <<'END';\r
 };\r
 \r
-static int FindIconByName( const char *name, guid_t *guid ) {\r
-       unsigned int i = 0; \r
-       for ( i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); i++ )\r
-       {\r
-               if ( !case_ignore_strcmp(name, default_guids[i].name)) {\r
-                       memcpy( guid, &(default_guids[i].guid), sizeof(guid_t));\r
-                       return 1;\r
-               }\r
-       }\r
-       return 0;\r
+static int FindIconByName(const char* name, guid_t* guid)\r
+{\r
+  for (unsigned int i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); ++i) {\r
+    if (!case_ignore_strcmp(name, default_guids[i].name)) {\r
+      *guid = default_guids[i].guid;\r
+      return 1;\r
+    }\r
+  }\r
+  return 0;\r
 }\r
 \r
-static int FindIconByGuid( guid_t *guid, char **name ) {\r
-       unsigned int i = 0; \r
-       for ( i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); i++ )\r
-       {\r
-               if ( !memcmp(guid, &default_guids[i].guid, sizeof(guid_t))) {\r
-                       *name = default_guids[i].name;\r
-                       return 1;\r
-               }\r
-       }\r
-       return 0;\r
+static int FindIconByGuid(const guid_t* guid, const char** name)\r
+{\r
+  for (unsigned int i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); ++i) {\r
+    /* don't compare any structure padding */\r
+    if ((guid->l == default_guids[i].guid.l) &&\r
+        memcmp(guid->s, default_guids[i].guid.s, sizeof(guid->s)) &&\r
+        memcmp(guid->c, default_guids[i].guid.c, sizeof(guid->c))) {\r
+      *name = default_guids[i].name;\r
+      return 1;\r
+    }\r
+  }\r
+  return 0;\r
 }\r
 END\r
 }\r
diff --git a/ozi.cc b/ozi.cc
index d6221406b30f01d2080dc3d77befa221f388afa2..87f7e036d9900ba9b316cff2210f13480aa382e3 100644 (file)
--- a/ozi.cc
+++ b/ozi.cc
 #include <QtCore/QString>         // for QString
 #include <QtCore/QStringList>     // for QStringList
 #include <QtCore/QTextStream>     // for QTextStream, operator<<, qSetRealNumberPrecision, QTextStream::FixedNotation
+#include <QtCore/QVector>         // for QVector
 #include <QtCore/Qt>              // for CaseInsensitive
 #include <QtCore/QtGlobal>        // for qPrintable
 
 #include "defs.h"
 #include "csv_util.h"             // for csv_stringclean
+#include "formspec.h"             // for FsChainAdd, FsChainFind, kFsOzi, FormatSpecificData
 #include "jeeps/gpsmath.h"        // for GPS_Math_Known_Datum_To_WGS84_M
 #include "src/core/datetime.h"    // for DateTime
 #include "src/core/textstream.h"  // for TextStream
 #define BADCHARS       ",\r\n"
 #define DAYS_SINCE_1990        25569
 
-struct ozi_fsdata {
-  format_specific_data fs;
-  int fgcolor;
-  int bgcolor;
+struct ozi_fsdata : FormatSpecificData {
+  ozi_fsdata() : FormatSpecificData(kFsOzi) {}
+
+  ozi_fsdata* clone() const override
+  {
+    return new ozi_fsdata(*this);
+  }
+
+  int fgcolor{0};
+  int bgcolor{65535};
 };
 
 static gpsbabel::TextStream* stream = nullptr;
@@ -169,29 +177,11 @@ ozi_close_io()
   stream = nullptr;
 }
 
-static void
-ozi_copy_fsdata(ozi_fsdata** dest, ozi_fsdata* src)
-{
-  /* No strings to mess with.  Straight forward copy. */
-  *dest = (ozi_fsdata*)xmalloc(sizeof(*src));
-  ** dest = *src;
-  (*dest)->fs.next = nullptr;
-}
-
-static void
-ozi_free_fsdata(void* fsdata)
-{
-  xfree(fsdata);
-}
-
 static
 ozi_fsdata*
 ozi_alloc_fsdata()
 {
-  auto* fsdata = (ozi_fsdata*) xcalloc(1, sizeof(ozi_fsdata));
-  fsdata->fs.type = FS_OZI;
-  fsdata->fs.copy = (fs_copy) ozi_copy_fsdata;
-  fsdata->fs.destroy = ozi_free_fsdata;
+  auto* fsdata = new ozi_fsdata;
 
   /* Provide defaults via command line defaults */
   fsdata->fgcolor = color_to_bbggrr(wptfgcolor);
@@ -844,8 +834,7 @@ data_read()
       case unknown_gpsdata:
         if (linecount > 4) {  /* skipping over file header */
           ozi_fsdata_used = true;
-          fs_chain_add(&(wpt_tmp->fs),
-                       (format_specific_data*) fsdata);
+          wpt_tmp->fs.FsChainAdd(fsdata);
           ozi_convert_datum(wpt_tmp);
           waypt_add(wpt_tmp);
         } else {
@@ -858,7 +847,7 @@ data_read()
       }
 
       if (!ozi_fsdata_used) {
-        fs_chain_destroy((format_specific_data*) fsdata);
+        delete fsdata;
       }
 
     } else {
@@ -878,7 +867,7 @@ ozi_waypt_pr(const Waypoint* wpt)
   int faked_fsdata = 0;
   int icon = 0;
 
-  auto* fs = (ozi_fsdata*) fs_chain_find(wpt->fs, FS_OZI);
+  const auto* fs = reinterpret_cast<ozi_fsdata*>(wpt->fs.FsChainFind(kFsOzi));
 
   if (!fs) {
     fs = ozi_alloc_fsdata();
index 0105e12be2c2e376edef6137d1db53565cdd60e0..175d7be09639b1877e069f1fa36b703049662707 100644 (file)
--- a/random.cc
+++ b/random.cc
@@ -139,7 +139,7 @@ random_generate_wpt(int i, const QDateTime& time, const Waypoint* prev)
 {
     auto wpt = new Waypoint;
     garmin_fs_t* gmsd = garmin_fs_alloc(-1);
-    fs_chain_add(&wpt->fs, (format_specific_data*) gmsd);
+    wpt->fs.FsChainAdd(gmsd);
 
     do {
       wpt->shortname = rand_str(8, "Wpt_%s");
index 7fbfa0900e8ffabd98f377d010490a85d0526ad6..3070ea02671bc94d60dfb8fd3f2c46da6ef4c6e4 100644 (file)
--- a/route.cc
+++ b/route.cc
@@ -371,7 +371,6 @@ computed_trkdata track_recompute(const route_head* trk)
 route_head::route_head() :
   rte_num(0),
   rte_waypt_ct(0),
-  fs(nullptr),
   // line_color(),
   line_width(-1),
   session(curr_session())
@@ -381,9 +380,7 @@ route_head::route_head() :
 route_head::~route_head()
 {
   waypoint_list.flush();
-  if (fs) {
-    fs_chain_destroy(fs);
-  }
+  fs.FsChainDestroy();
 }
 
 int RouteList::waypt_count() const
@@ -483,7 +480,7 @@ RouteList::copy(RouteList** dst) const
     rte_new->rte_urls = rte_old->rte_urls;
     rte_new->rte_num = rte_old->rte_num;
     // rte_waypt_ct created below with add_wpt.
-    rte_new->fs = fs_chain_copy(rte_old->fs);
+    rte_new->fs = rte_old->fs.FsChainCopy();
     rte_new->line_color = rte_old->line_color;
     rte_new->line_width = rte_old->line_width;
     rte_new->session = rte_old->session;
index 4bdae190ad9ef430073b01f1974df4703d9d1ced..7563eba655a76939fb050155e3c6e0d34417a020 100644 (file)
@@ -40,11 +40,21 @@ xml_tag* xml_findfirst(xml_tag* root, const QString& tagname);
 xml_tag* xml_findnext(xml_tag* root, xml_tag* cur, const QString& tagname);
 QString xml_attribute(const QXmlStreamAttributes& attributes, const QString& attrname);
 
-struct fs_xml {
-  format_specific_data fs;
+struct fs_xml : FormatSpecificData {
+  explicit fs_xml(FsType type) : FormatSpecificData(type) {}
+private:
+  fs_xml(const fs_xml&) = default;
+public:
+  fs_xml& operator=(const fs_xml&) = delete;
+  fs_xml(fs_xml&&) = delete;
+  fs_xml& operator=(fs_xml&&) = delete;
+  ~fs_xml() override;
+
+  fs_xml* clone() const override;
+
   xml_tag* tag{nullptr};
 };
 
-fs_xml* fs_xml_alloc(long type);
+fs_xml* fs_xml_alloc(FsType type);
 
 #endif // SRC_CORE_XMLTAG_H
diff --git a/text.cc b/text.cc
index 3b6b1302791bb79dba6dedf66c5049defc084e57..bc1aa866a4956f395869ec213cdb0b9b7e1ef8a6 100644 (file)
--- a/text.cc
+++ b/text.cc
@@ -27,6 +27,7 @@
 #include <QtCore/Qt>               // for CaseInsensitive
 
 #include "defs.h"
+#include "formspec.h"              // for FsChainFind, kFsGpx
 #include "gbfile.h"                // for gbfprintf, gbfputs, gbfclose, gbfopen, gbfile
 #include "jeeps/gpsmath.h"         // for GPS_Math_WGS84_To_UTM_EN
 #include "src/core/datetime.h"     // for DateTime
@@ -172,69 +173,67 @@ text_disp(const Waypoint* wpt)
     gbfputs("\n", file_out);
   }
 
-  fs_xml* fs_gpx = nullptr;
   if (includelogs) {
-    fs_gpx = (fs_xml*)fs_chain_find(wpt->fs, FS_GPX);
-  }
+    const auto* fs_gpx = reinterpret_cast<fs_xml*>(wpt->fs.FsChainFind(kFsGpx));
+    if (fs_gpx && fs_gpx->tag) {
+      xml_tag* root = fs_gpx->tag;
+      xml_tag* curlog = xml_findfirst(root, "groundspeak:log");
+      while (curlog) {
+        time_t logtime = 0;
+        gbfprintf(file_out, "\n");
+
+        xml_tag* logpart = xml_findfirst(curlog, "groundspeak:type");
+        if (logpart) {
+          gbfputs(logpart->cdata, file_out);
+          gbfputs(" by ", file_out);
+        }
 
-  if (fs_gpx && fs_gpx->tag) {
-    xml_tag* root = fs_gpx->tag;
-    xml_tag* curlog = xml_findfirst(root, "groundspeak:log");
-    while (curlog) {
-      time_t logtime = 0;
-      gbfprintf(file_out, "\n");
-
-      xml_tag* logpart = xml_findfirst(curlog, "groundspeak:type");
-      if (logpart) {
-        gbfputs(logpart->cdata, file_out);
-        gbfputs(" by ", file_out);
-      }
+        logpart = xml_findfirst(curlog, "groundspeak:finder");
+        if (logpart) {
+          gbfputs(logpart->cdata, file_out);
+          gbfputs(" on ", file_out);
+        }
 
-      logpart = xml_findfirst(curlog, "groundspeak:finder");
-      if (logpart) {
-        gbfputs(logpart->cdata, file_out);
-        gbfputs(" on ", file_out);
-      }
+        logpart = xml_findfirst(curlog, "groundspeak:date");
+        if (logpart) {
+          logtime = xml_parse_time(logpart->cdata).toTime_t();
+          struct tm* logtm = localtime(&logtime);
+          if (logtm) {
+            gbfprintf(file_out,
+                      "%4.4d-%2.2d-%2.2d\n",
+                      logtm->tm_year+1900,
+                      logtm->tm_mon+1,
+                      logtm->tm_mday);
+          }
+        }
 
-      logpart = xml_findfirst(curlog, "groundspeak:date");
-      if (logpart) {
-        logtime = xml_parse_time(logpart->cdata).toTime_t();
-        struct tm* logtm = localtime(&logtime);
-        if (logtm) {
-          gbfprintf(file_out,
-                    "%4.4d-%2.2d-%2.2d\n",
-                    logtm->tm_year+1900,
-                    logtm->tm_mon+1,
-                    logtm->tm_mday);
+        logpart = xml_findfirst(curlog, "groundspeak:log_wpt");
+        if (logpart) {
+          double lat = xml_attribute(logpart->attributes, "lat").toDouble();
+          double lon = xml_attribute(logpart->attributes, "lon").toDouble();
+          char* coordstr = pretty_deg_format(lat, lon, degformat[2], " ", 0);
+          gbfprintf(file_out, "%s\n", coordstr);
+          xfree(coordstr);
         }
-      }
 
-      logpart = xml_findfirst(curlog, "groundspeak:log_wpt");
-      if (logpart) {
-        double lat = xml_attribute(logpart->attributes, "lat").toDouble();
-        double lon = xml_attribute(logpart->attributes, "lon").toDouble();
-        char* coordstr = pretty_deg_format(lat, lon, degformat[2], " ", 0);
-        gbfprintf(file_out, "%s\n", coordstr);
-        xfree(coordstr);
-      }
+        logpart = xml_findfirst(curlog, "groundspeak:text");
+        if (logpart) {
+          QString encstr = xml_attribute(logpart->attributes, "encoded");
+          bool encoded = !encstr.startsWith('F', Qt::CaseInsensitive);
 
-      logpart = xml_findfirst(curlog, "groundspeak:text");
-      if (logpart) {
-        QString encstr = xml_attribute(logpart->attributes, "encoded");
-        bool encoded = !encstr.startsWith('F', Qt::CaseInsensitive);
+          QString s;
+          if (txt_encrypt && encoded) {
+            s = rot13(logpart->cdata);
+          } else {
+            s = logpart->cdata;
+          }
 
-        QString s;
-        if (txt_encrypt && encoded) {
-          s = rot13(logpart->cdata);
-        } else {
-          s = logpart->cdata;
+          gbfputs(s, file_out);
         }
 
-        gbfputs(s, file_out);
+        gbfprintf(file_out, "\n");
+        curlog = xml_findnext(root, curlog, "groundspeak:log");
       }
-
-      gbfprintf(file_out, "\n");
-      curlog = xml_findnext(root, curlog, "groundspeak:log");
     }
   }
   if (! suppresssep) {
index 63a966e250959af61359ba6060a3bd83e383e584..7c4d3fe22c1989264956f18e5b9e61ebb2be7e12 100644 (file)
--- a/unicsv.cc
+++ b/unicsv.cc
@@ -993,7 +993,7 @@ unicsv_parse_one_line(const QString& ibuf)
       gmsd = garmin_fs_t::find(wpt);
       if (! gmsd) {
         gmsd = garmin_fs_alloc(-1);
-        fs_chain_add(&wpt->fs, (format_specific_data*) gmsd);
+        wpt->fs.FsChainAdd(gmsd);
       }
       switch (unicsv_fields_tab[column]) {
       case fld_garmin_city:
index 65e9c0a93f8586fa7483e29249843235148e7b89..e7e942b8634ad530b3e15c58ab75ca7f553f0acb 100644 (file)
--- a/waypt.cc
+++ b/waypt.cc
@@ -32,7 +32,7 @@
 #include <QtCore/QtGlobal>      // for qPrintable
 
 #include "defs.h"
-#include "garmin_fs.h"          // for garmin_ilink_t, garmin_fs_t, GMSD_FIND, garmin_fs_p
+#include "garmin_fs.h"          // for garmin_ilink_t, garmin_fs_t, GMSD_FIND
 #include "grtcirc.h"            // for RAD, gcdist, heading_true_degrees, radtometers
 #include "session.h"            // for curr_session, session_t
 #include "src/core/datetime.h"  // for DateTime
@@ -251,7 +251,7 @@ double
 waypt_distance_ex(const Waypoint* A, const Waypoint* B)
 {
   double res = 0;
-  garmin_fs_p gmsd;
+  garmin_fs_t* gmsd;
 
   if ((A == nullptr) || (B == nullptr)) {
     return 0;
@@ -404,7 +404,6 @@ Waypoint::Waypoint() :
   temperature(0),
   odometer_distance(0),
   gc_data(&Waypoint::empty_gc_data),
-  fs(nullptr),
   session(curr_session()),
   extra_data(nullptr)
 {
@@ -415,7 +414,7 @@ Waypoint::~Waypoint()
   if (gc_data != &Waypoint::empty_gc_data) {
     delete gc_data;
   }
-  fs_chain_destroy(fs);
+  fs.FsChainDestroy();
 }
 
 Waypoint::Waypoint(const Waypoint& other) :
@@ -446,7 +445,6 @@ Waypoint::Waypoint(const Waypoint& other) :
   temperature(other.temperature),
   odometer_distance(other.odometer_distance),
   gc_data(other.gc_data),
-  fs(other.fs),
   session(other.session),
   extra_data(other.extra_data)
 {
@@ -456,7 +454,7 @@ Waypoint::Waypoint(const Waypoint& other) :
   }
 
   // deep copy fs chain data.
-  fs = fs_chain_copy(other.fs);
+  fs = other.fs.FsChainCopy();
 
   // note: session is not deep copied.
   // note: extra_data is not deep copied.
@@ -470,7 +468,7 @@ Waypoint& Waypoint::operator=(const Waypoint& rhs)
     if (gc_data != &Waypoint::empty_gc_data) {
       delete gc_data;
     }
-    fs_chain_destroy(fs);
+    fs.FsChainDestroy();
 
     // allocate and copy
     latitude = rhs.latitude;
@@ -500,7 +498,6 @@ Waypoint& Waypoint::operator=(const Waypoint& rhs)
     temperature = rhs.temperature;
     odometer_distance = rhs.odometer_distance;
     gc_data = rhs.gc_data;
-    fs = rhs.fs;
     session = rhs.session;
     extra_data = rhs.extra_data;
     // deep copy geocache data unless it is the special static empty_gc_data.
@@ -509,7 +506,7 @@ Waypoint& Waypoint::operator=(const Waypoint& rhs)
     }
 
     // deep copy fs chain data.
-    fs = fs_chain_copy(rhs.fs);
+    fs = rhs.fs.FsChainCopy();
 
     // note: session is not deep copied.
     // note: extra_data is not deep copied.
diff --git a/xcsv.cc b/xcsv.cc
index 8a0725bd26b3b99390f47a52069efe6bd0d8d12a..61ce7bc41569417cc4de08f9cddbef08ae373c23 100644 (file)
--- a/xcsv.cc
+++ b/xcsv.cc
@@ -387,7 +387,7 @@ XcsvFormat::gmsd_init(Waypoint* wpt)
   garmin_fs_t* gmsd = garmin_fs_t::find(wpt);
   if (gmsd == nullptr) {
     gmsd = garmin_fs_alloc(-1);
-    fs_chain_add(&wpt->fs, (format_specific_data*) gmsd);
+    wpt->fs.FsChainAdd(gmsd);
   }
   return gmsd;
 }
index 1aa7f6c846daac79ed1886eb08cebfe67088ddf8..da2f71d9b5f08bdc01ec90c58156135185ed7b5b 100644 (file)
--- a/xmltag.cc
+++ b/xmltag.cc
@@ -60,36 +60,20 @@ copy_xml_tag(xml_tag** copy, xml_tag* src, xml_tag* parent)
   copy_xml_tag(&(res->child), src->child, res);
 }
 
-static void
-fs_xml_destroy(void* fs)
+fs_xml::~fs_xml()
 {
-  auto* xml = (fs_xml*)fs;
-  if (xml) {
-    free_xml_tag(xml->tag);
-  }
-  delete xml;
+  free_xml_tag(tag);
 }
 
-static void
-fs_xml_copy(void** copy, void* source)
+fs_xml* fs_xml::clone() const
 {
-  auto* src = (fs_xml*)source;
-  if (!source) {
-    *copy = nullptr;
-    return;
-  }
-  auto* res = new fs_xml;
-  *copy = res;
-
-  res->fs = src->fs;
-  copy_xml_tag(&(res->tag), src->tag, nullptr);
+  auto* copy = new fs_xml(*this);
+  copy_xml_tag(&(copy->tag), tag, nullptr);
+  return copy;
 }
 
-fs_xml* fs_xml_alloc(long type)
+fs_xml* fs_xml_alloc(FsType type)
 {
-  auto* result = new fs_xml;
-  result->fs.type = type;
-  result->fs.copy = fs_xml_copy;
-  result->fs.destroy = fs_xml_destroy;
+  auto* result = new fs_xml(type);
   return result;
 }